Submitted by  Digpal Singh Jhala MSc IT  Sem II 2009-2011 Submitted to Ms. Namita Jain MADAM
<ul><li>A program in exucution(process). </li></ul><ul><li>Sequential manner. </li></ul><ul><li>At a time only one instruc...
<ul><li>Each  process  provides the resources needed to execute a program </li></ul><ul><li>A  thread  is the entity withi...
<ul><li>An application can use the  thread pool  to reduce the number of application threads and provide management of the...
 
Unix process  Threads within a unix process
Consider An Executing Program <ul><li>Sometimes we call a program in the system a job or a process </li></ul><ul><li>We sp...
Basic Program Execution <ul><li>When a program runs, the  program counter  keeps track of the next instruction to be execu...
 
Process States <ul><li>A process may go through a number of different states as it is executed </li></ul><ul><li>When a pr...
The Five State Model READY NEW WAITING RUNNING TERMINATED admitted time-out interrupt OS services request I/O or event wai...
Which state is my job in? <ul><li>On  some systems , you can look at the status of your jobs and even others’ jobs </li></...
Context Switching <ul><li>Strictly speaking, only one process can run on the CPU at any given time </li></ul><ul><li>To sh...
Process Control Block (PCB) <ul><li>Is a small data structure for the job submitted to the operating system </li></ul><ul>...
Threads versus Processes <ul><li>A  thread  is a single path of instruction in a program </li></ul><ul><ul><li>threads sha...
Program  Code  (note only  one copy  needed)  Thread 1 Thread 2 PC PC Program Stack Stack Shared Data
Types of Threads <ul><li>User Threads </li></ul><ul><ul><li>Designed for applications to use </li></ul></ul><ul><ul><li>Ma...
CPU scheduling policies <ul><li>Many conflicting goals: maximum number of jobs processed, importance of the jobs, responsi...
Categories of policies <ul><li>Multi-user CPU scheduling policies </li></ul><ul><ul><li>variants of Round Robin (preemptiv...
Round Robin <ul><li>Almost all computers today use some form of  time-sharing , even PCs </li></ul><ul><li>Time divided in...
So How Are Processes Scheduled? <ul><li>Let’s assume that we know the arrival times of the jobs, and how many CPU cycles e...
Simple Example 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles:
Round Robin (RR), First Stages A 0  2  4 A
Round Robin, Continued (2) A 0  2  4  6  8 A B C
Round Robin, Completed A B C D A B A C A C A 0  2  4  6  8  10  12 13  15  17 18  20
Simple Example 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles:
Shortest Remaining Time (SRT) (also preemptive) A D A C B 0  4  7  9  14  20
Shortest Job Next (SJN) (non-preemptive) A D C B 0  10  12  15  20
First Come, First Served (FCFS) (non-preemptive) A D C B 0  10  13  18  20
Turnaround Time <ul><li>Is the time from job arrival to job completion </li></ul><ul><ul><li>T(j i ) = Finish(j i ) -  Arr...
Calculating Average Turnaround Time for FCFS AVERAGE = 11.25 Job: Arrives: Finishes: Turnaround: A B C D 0 4 5 7 10 13 18 ...
Simple Example (Extended) here higher priority values mean you go first… 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles...
Multilevel Priority <ul><li>Many different priority levels, 1, 2, 3, …n  where 1 is lowest and n is highest </li></ul><ul>...
Multilevel Priority (ML) (preemptive) A C A D B 0  5  10  15  17  20 since each process was in a different queue, we didn’...
Multilevel Feedback (MLF) (preemptive) <ul><li>There are several priority levels 1, 2, … n </li></ul><ul><li>Processes sta...
<ul><li>Top levels should be close to pure RR (for good response time), </li></ul><ul><li>bottom queues should be close to...
Multilevel Feedback Time Limits <ul><li>The time limit at each priority level varies as a function of level </li></ul><ul>...
Simple Example (Extended) here higher priority values mean you go first… 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles...
Multilevel Feedback Schedule Assumptions:  T = 2;  RR Quantum = 2 at each level A B C D 1 2 1 1 1 A 2 2 2 3 B C A 0  2  4 ...
<ul><li>THANKYOU </li></ul>
Upcoming SlideShare
Loading in …5
×

Process management

1,331 views
1,159 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,331
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Process management

  1. 1. Submitted by Digpal Singh Jhala MSc IT Sem II 2009-2011 Submitted to Ms. Namita Jain MADAM
  2. 2. <ul><li>A program in exucution(process). </li></ul><ul><li>Sequential manner. </li></ul><ul><li>At a time only one instruction. </li></ul><ul><li>Process is more than a program tool. </li></ul><ul><li>It include current activity as represented by the value of program counter.& process state containing global variables. </li></ul><ul><li>Program itself is not process. </li></ul>
  3. 3. <ul><li>Each process provides the resources needed to execute a program </li></ul><ul><li>A thread is the entity within a process that can be scheduled for execution. </li></ul><ul><li>preemptive multitasking </li></ul><ul><li>A job object allows groups of processes to be managed as a unit. Job objects are namable, securable, sharable objects that control attributes of the processes associated with them </li></ul>
  4. 4. <ul><li>An application can use the thread pool to reduce the number of application threads and provide management of the worker threads </li></ul><ul><li>User-mode scheduling (UMS) is a light-weight mechanism that applications can use to schedule their own threads. </li></ul><ul><li>A fiber is a unit of execution that must be manually scheduled by the application. Fibers run in the context of the threads that schedule them </li></ul>
  5. 6. Unix process Threads within a unix process
  6. 7. Consider An Executing Program <ul><li>Sometimes we call a program in the system a job or a process </li></ul><ul><li>We speak of the terms process and job interchangeably sometimes, but they are different </li></ul><ul><li>A job is an activity submitted to the operating system to be done </li></ul><ul><li>A process is an activity being worked on by the system </li></ul><ul><li>Thus {processes} {jobs} </li></ul>
  7. 8. Basic Program Execution <ul><li>When a program runs, the program counter keeps track of the next instruction to be executed </li></ul><ul><li>registers keep values of current variables </li></ul><ul><ul><li>together the program counter and variables for a program are the program state </li></ul></ul><ul><li>stack space in memory is used to keep values of variables from subroutines that have to be returned to </li></ul>
  8. 10. Process States <ul><li>A process may go through a number of different states as it is executed </li></ul><ul><li>When a process requests a resource, for example, it may have to wait for that resource to be given by the OS </li></ul><ul><li>In addition to I/O, memory, and the like, processes must share the CPU </li></ul><ul><ul><li>processes are “unaware” of each others CPU usage </li></ul></ul><ul><ul><li>virtualization allows them to share the CPU </li></ul></ul>
  9. 11. The Five State Model READY NEW WAITING RUNNING TERMINATED admitted time-out interrupt OS services request I/O or event wait scheduler dispatch deallocate resources and exit Arc labels show typical events which cause that transition
  10. 12. Which state is my job in? <ul><li>On some systems , you can look at the status of your jobs and even others’ jobs </li></ul><ul><ul><li>on UNIX, type ps at the prompt </li></ul></ul><ul><ul><li>Note: “nice” command in UNIX </li></ul></ul><ul><ul><li>print jobs on Mac or Windows </li></ul></ul><ul><li>The number of states possible may differ from our model—after all, it is only a model </li></ul>
  11. 13. Context Switching <ul><li>Strictly speaking, only one process can run on the CPU at any given time </li></ul><ul><li>To share the CPU, the operating system must save the state of one process, then load another’s program and data </li></ul><ul><li>Hardware has to help with the stopping of programs (time-out interrupt) </li></ul><ul><li>This context switch does no useful work—it is an overhead expense </li></ul>
  12. 14. Process Control Block (PCB) <ul><li>Is a small data structure for the job submitted to the operating system </li></ul><ul><li>Contents (four major parts): </li></ul><ul><ul><li>unique identification </li></ul></ul><ul><ul><li>process status (ie: where in 5 state model) </li></ul></ul><ul><ul><li>process state (ie: instruction counter, memory map, list of resources allocated, priority) </li></ul></ul><ul><ul><li>other useful information (eg: usage stats) </li></ul></ul><ul><li>Schedulers use instead of entire process (why?) </li></ul>
  13. 15. Threads versus Processes <ul><li>A thread is a single path of instruction in a program </li></ul><ul><ul><li>threads share a process! </li></ul></ul><ul><li>All threads in a process share memory space and other resources </li></ul><ul><li>Each thread has its own CPU state (registers, program counter) and stack </li></ul><ul><li>May be scheduled by the process or by the kernel </li></ul><ul><li>Threads are efficient, but lack protection from each other </li></ul>
  14. 16. Program Code (note only one copy needed) Thread 1 Thread 2 PC PC Program Stack Stack Shared Data
  15. 17. Types of Threads <ul><li>User Threads </li></ul><ul><ul><li>Designed for applications to use </li></ul></ul><ul><ul><li>Managed by application programmer </li></ul></ul><ul><ul><li>May not get used! </li></ul></ul><ul><li>Kernel Threads </li></ul><ul><ul><li>Managed by OS </li></ul></ul><ul><ul><li>More overhead </li></ul></ul>
  16. 18. CPU scheduling policies <ul><li>Many conflicting goals: maximum number of jobs processed, importance of the jobs, responsiveness to users, how long a job might be forced to wait, I/O utilization, CPU utilization, etc. </li></ul><ul><li>Preemptive versus Nonpreemptive policies </li></ul>
  17. 19. Categories of policies <ul><li>Multi-user CPU scheduling policies </li></ul><ul><ul><li>variants of Round Robin (preemptive) </li></ul></ul><ul><li>Batch systems </li></ul><ul><ul><li>First Come, First Served (nonpreemptive) </li></ul></ul><ul><ul><li>Shortest Job First (nonpreemptive) </li></ul></ul><ul><ul><li>Shortest Remaining Time (preemptive) </li></ul></ul><ul><ul><li>Priority Scheduling (preemptive) </li></ul></ul>
  18. 20. Round Robin <ul><li>Almost all computers today use some form of time-sharing , even PCs </li></ul><ul><li>Time divided into CPU quanta (5-100 ms) </li></ul><ul><li>“ Proper” time quantum size? Two rules of thumb: </li></ul><ul><ul><li>At least 100 times larger than a context switch </li></ul></ul><ul><ul><li>(if not, context switch takes too much time) </li></ul></ul><ul><ul><li>At least 80% of CPU cycles allocated run to completion </li></ul></ul><ul><ul><li>(if not, RR degenerates towards FCFS) </li></ul></ul>
  19. 21. So How Are Processes Scheduled? <ul><li>Let’s assume that we know the arrival times of the jobs, and how many CPU cycles each will take; for RR, assume quantum = 2 </li></ul><ul><li>Real processors don’t know arrival times and CPU cycles required in advance, so we can’t schedule on this basis! </li></ul><ul><li>Let’s try out some of the algorithms… </li></ul>
  20. 22. Simple Example 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles:
  21. 23. Round Robin (RR), First Stages A 0 2 4 A
  22. 24. Round Robin, Continued (2) A 0 2 4 6 8 A B C
  23. 25. Round Robin, Completed A B C D A B A C A C A 0 2 4 6 8 10 12 13 15 17 18 20
  24. 26. Simple Example 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles:
  25. 27. Shortest Remaining Time (SRT) (also preemptive) A D A C B 0 4 7 9 14 20
  26. 28. Shortest Job Next (SJN) (non-preemptive) A D C B 0 10 12 15 20
  27. 29. First Come, First Served (FCFS) (non-preemptive) A D C B 0 10 13 18 20
  28. 30. Turnaround Time <ul><li>Is the time from job arrival to job completion </li></ul><ul><ul><li>T(j i ) = Finish(j i ) - Arrive(j i ) </li></ul></ul><ul><ul><li>(and where might such information be stored?) </li></ul></ul><ul><li>We often want to know what the average turnaround time is for a given schedule </li></ul><ul><li>Let’s calculate the turnaround time for the last schedule… </li></ul>
  29. 31. Calculating Average Turnaround Time for FCFS AVERAGE = 11.25 Job: Arrives: Finishes: Turnaround: A B C D 0 4 5 7 10 13 18 20 10 9 13 13
  30. 32. Simple Example (Extended) here higher priority values mean you go first… 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles: Priority: 3 1 4 2
  31. 33. Multilevel Priority <ul><li>Many different priority levels, 1, 2, 3, …n where 1 is lowest and n is highest </li></ul><ul><li>A process is permanently assigned to one priority level </li></ul><ul><li>A RR scheduler handles processes of equal priority within a level </li></ul>
  32. 34. Multilevel Priority (ML) (preemptive) A C A D B 0 5 10 15 17 20 since each process was in a different queue, we didn’t have to calculate RR within the queue
  33. 35. Multilevel Feedback (MLF) (preemptive) <ul><li>There are several priority levels 1, 2, … n </li></ul><ul><li>Processes start at the highest priority level n </li></ul><ul><li>A maximum time T is associated with each level—if the process uses more than that amount of time, it moves to a lower priority level </li></ul><ul><li>RR is used to schedule within each level </li></ul>
  34. 36. <ul><li>Top levels should be close to pure RR (for good response time), </li></ul><ul><li>bottom queues should be close to pure FCFS (for good throughput). </li></ul><ul><li>Both can be achieved if all levels are SRR with varying parameters. </li></ul>
  35. 37. Multilevel Feedback Time Limits <ul><li>The time limit at each priority level varies as a function of level </li></ul><ul><ul><li>T P = T for P = n </li></ul></ul><ul><ul><li>T P = 2T P+1 for 1 ≤ P < n </li></ul></ul><ul><ul><li>Usually T is set to some small, reasonable amount appropriate for the particular system </li></ul></ul><ul><li>If a process uses up time available at level 1, it is assumed to be a runaway process and is terminated </li></ul>
  36. 38. Simple Example (Extended) here higher priority values mean you go first… 0 4 5 7 A B C D 10 3 5 2 Arrives: Job: CPU Cycles: Priority: 3 1 4 2
  37. 39. Multilevel Feedback Schedule Assumptions: T = 2; RR Quantum = 2 at each level A B C D 1 2 1 1 1 A 2 2 2 3 B C A 0 2 4 6 8 10 12 13 16 20
  38. 40. <ul><li>THANKYOU </li></ul>

×