Download process management in mach

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
PROCESS MANAGEMENT IN MACH
Praseetha S Nair
M.Tech(CS)
Processes
 Process consist of an address space and a collection of threads
that execute in that address space.
 Execution is associated with threads.
A Mach process
Other process properties
Suspend counter
Scheduling parameters
Emulation address
Statistics
Address
space
Thread
Process port
Bootstrap
port
Exception
port
Registered
port
kernel
Ports
 Process port:-to communicate with kernel
 Bootstrap port:-for initialization when a process start up.
 Exception port:-reports exceptions caused by process.
 Registered port:-to provide a way for the processes to
communicate with standard system servers
Other properties
 A process is runnable or blocked, independent of state of
threads.
 If runnable, those threads are also runnable can be scheduled
and run
 If blocked, threads may not run, no matter what state they
are in.
 Scheduling parameters:-ability to specify which processors
the process' threads can run on
 Emulation address:-set to tell the kernel where in the address
space system call handlers are located
 Statistics:-includes amount of memory consumed, run time
of threads and so on
Process management primitives
Call
Description
Create
Create a new process, inheriting certain properties
Terminate
Kill a specified process
Suspend
Increment suspend counter
Resume
Decrement suspend counter. If it is 0, unblock the process
Priority
Set the priority for current or future threads
Assign
Tell which processor new threads should run on
Info
Return information about execution time, memory usage, etc.
Threads
Return a list of the process’ threads
Threads
 Execute instructions and manipulate their registers and





address spaces.
Each thread belong to one process
Threads have per-thread resources
Thread port:-use to invoke thread-specific kernel services
Mach threads managed by kernel, so called heavyweight
threads
Thread creation and destruction done by kernel.
 On a single CPU system, threads are timeshared
 On a multiprocessor, several threads can be active at same




time.
Thread can be runnable or blocked.
Mach’s approach is C threads package
Make kernel thread primitives available to users in simple
and convenient form.
Provide 16 calls for direct thread manipulation.
Principal C thread calls for direct
thread management
Call
Description
Fork
Create a new thread running the same code as the
parent thread
Exit
Terminate the calling thread
Join
Suspend the caller until a specified thread exits
Detach
Announce that the thread will never be jointed (waited
for)
Yield
Give up the CPU voluntarily
Self
Return the calling thread’s identity to it
 Synchronization is done using mutexes and condition




variables.
Mutex primitives are lock, trylock and unlock
Primitives are also provided to allocate and free mutexes
Operations on conditional variables are signal, wait and
broadcast
Used to allow threads to block on a condition and later be
awakened when another thread cause that condition to occur.
Implementation of C threads in Mach
(a)
(b)
(c)
(d)
 In (a), all C thread uses one kernel thread
 In (b), use one Mach thread per thread
 In (c),one thread per process
 In (d), arbitrary number of user threads to be mapped to
arbitrary number of kernel threads
Scheduling
 CPUs in multiprocessor can be assigned to processor set
 Threads also can be assigned to processor sets.
 Job of scheduling algorithm is to assign threads to CPU in an
efficient way
 Thread scheduling in Mach is based on priorities.
 From 0 to some maximum(31 or 127)
 0-highest. 31 or 127-lowest
 Each thread has 3 priorities
 1.Base priority:-thread can set itself
 2.lowest numerical value thread may set it base priority to
 3.current priority:-computed by the kernel by adding to the
base priority a function based on the
thread's recent CPU usage
Scheduling
Global run queue for processor set 1
Priority
(high) 0
Low 31
:Free
Count: 6
Hint: 2
Global run queue for processor set 2
0
31
:Busy
Count: 7
Hint: 4
 Associated with each processor set is an array of run queues
 Array has 32 queues
 Thread not runnable not included in run queue
 Each run queue has 3 variables
1.mutex
2.count
3.hint
 Each CPU has its own local run queue.
 Holds threads that are permanently bound to it
Scheduling algorithm
 When a thread blocks, exits or uses up its quantum, CPU looks on







local run queue to see if there are any active threads.
If it is nonzero, search for highest priority thread.
If empty, same algorithm applied to global run queue.
If no thread to run, a special idle thread is run until some become
ready
If a runnable thread found, scheduled and run for one quantum.
After one quantum, check local and global queue for any runnable
thread.
If found, thread switch occur
If not found, thread run for another one quantum
THANK YOU