Tuesday, March 18

Linux Process Management


Abstract

In theory, there is no difference in theory and practice, but in practice, there is. Learning the standard operating system concepts breaks the ice for studying a practical operating system implementation. In this seminar we will have a look on Linux process management and scheduler. I will explain the Linux 2.6.8.1 CPU scheduler. Process management is also in context of this scheduler. The various attributes of the process descriptor are used to manage and control the lifetime of a process. We will see in detail how the process descriptor is implemented. We will see the data structures kernel uses for managing all the processes.

Waking Up

The try_to_wake_up() function is responsible for trying to wake up tasks. When a waitqueue is told to wake up, try_to_wake_up() is called on each task in the waitqueue, and then tasks are removed from the waitqueue. The task is marked TASK_RUNNING, and then it is added back to the appropriate runqueue to be scheduled again.


Waitqueues

A waitqueue is essentially a list of tasks waiting for some event or condition to occur. When that event occurs, code controlling that event will tell the waitqueue to wake up all of the tasks in it. It is a centralized place for event notifications to be “posted.” Sleeping tasks are added to waitqueues before going to sleep in order to be woken up when the event they are waiting for occurs.

Sleeping and Waking Tasks

A task or process cannot always be running. If a task needs input from user then it can not move further until and unless the user types the input string in. It may take a few seconds. But in these few seconds number of other processes may complete their execution. So this process is blocked until user enters the input.

Dynamic Priority

The Linux 2.6.8.1 scheduler assigns high dynamic priorities to I/O bound tasks and penalizes  CPU bound tasks. It subtracts –5 to +5 values from the task’s static priority value.The newly calculated priority is called a task’s dynamic priority, and is accessible via the task’s prio variable (e.g. p->prio where p is a task). If a task is interactive (the scheduler’s term for I/O bound), its priority is boosted. If it is a CPU hog, it will get a penalty.

Locking


Only one task may modify a CPU’s runqueue at any given time, and as such any task that wishes to modify a runqueue must obtain its lock first. Obtaining multiple runqueue locks must be done by order of ascending runqueue address in order to avoid deadlocks. A convenient function for obtaining two runqueue locks is double_rq_lock(rq1, rq2), which handles lock ordering itself. Its opposite, double_rq_unlock(rq1,rq2), does the same but unlocks instead of locks.


0 comments:


Home About-us Computer Science Electronics Mechanical Electrical IT Civil
Copyright © 2018 www.seminartopics.org | All Rights Reserved. Design By Templateclue