Presentation is loading. Please wait.

Presentation is loading. Please wait.

Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.1 Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch.

Similar presentations


Presentation on theme: "Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.1 Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch."— Presentation transcript:

1 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.1 Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch. 4.3 - 4.5

2 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.2 Operating System Concepts Process Scheduling Queues Recall the process migration through multiple queues: Job queue – set of all processes in the system. Ready queue – set of all processes residing in main memory, ready and waiting to execute. Device queues – set of processes waiting for an I/O device.

3 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.3 Operating System Concepts Ready Queue And Various I/O Device Queues

4 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.4 Operating System Concepts Representation of Process Scheduling

5 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.5 Operating System Concepts Schedulers Long-term scheduler (or job scheduler)  selects which processes should be brought into the ready queue.  Is necessary when there are more processes submitted than can be stored in memory.  Absent or minimal on some systems (e.g. UNIX) Short-term scheduler (or CPU scheduler)  selects which process should be executed next among processes in the ready queue.  Allocates the CPU to next process Medium-term scheduler (swapper)  Temporarily removes process from memory and stores it on disk.  Later the process can be swapped back in.

6 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.6 Operating System Concepts Addition of Medium Term Scheduling We will draw a new state diagram in class that includes states for processes that have been swapped out.

7 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.7 Operating System Concepts Questions about Swapping Why are there two suspend states instead of one? When the OS needs memory, what processes get suspended? When memory becomes available, which processes have highest priority to be placed in the ready queue?

8 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.8 Operating System Concepts Frequency of Execution Short-term scheduler is invoked very frequently (milliseconds)  (must be fast) If it executes 1 time per 100 msec and takes 10 msec to execute, what percentage of CPU time is used by the scheduler? Long-term scheduler is invoked very infrequently (seconds, minutes)  (may be slow).  The long-term scheduler controls the degree of multiprogramming.  To keep the degree of multiprogramming stable, the scheduler must bring in new processes as old processes leave the system. Medium term scheduler has an intermediate frequency of execution.

9 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.9 Operating System Concepts I/O bound vs. CPU bound A process may be described as I/O bound or CPU bound. I/O bound processes spend more time doing I/O than using the CPU. CPU bound processes spend more time doing computation than using I/O Process Mix:  Ideally we want a good balance between CPU bound and I/O bound processes  What happens if all processes are I/O bound?  What happens if all processes are CPU bound? Long term and medium term (swapper) schedulers can be used to maintain a good process mix.

10 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.10 Operating System Concepts Context Switch When CPU switches to another process, the system must:  save the state of the old process  load the saved state for the new process.  This is known as a context switch.  The context of a process is represented by the PCB. Context-switch time is overhead; the system does no useful work while switching. The speed is dependent on hardware support, and may range between 1 and 1000 microseconds on different machines. Example: The SUN UltraSPARC has multiple sets of registers. To switch contexts, it just moves a pointer to a new register set.

11 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.11 Operating System Concepts Process Creation Parent processes create children processes, which, in turn create other processes, forming a tree of processes. UNIX processes: In UNIX, the swapper is the ancestor of all processes. PID = 0 (process ID) The first child of the swapper is the INIT process. PID = 1 The INIT process is the parent process to all login processes.

12 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.12 Operating System Concepts Diagram of UNIX Process tree We will diagram this in class.

13 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.13 Operating System Concepts Resources and Execution Resource sharing  EITHER: parent and children share all resources.  Children share subset of parent’s resources.  OR: Parent and child share no resources.  Why is it a good idea to restrict the child to a subset of the parent's resources? Execution  EITHER: Parent and children execute concurrently.  OR: Parent waits until some or all children terminate.

14 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.14 Operating System Concepts More on Child Processes Address space  EITHER: Child is a duplicate of the parent.  OR: Child has a program loaded into it. UNIX examples  fork system call creates new process (duplicate of parent).  exec system call used after a fork to replace the process’ memory space with a new program.  (we'll see how these work later).

15 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.15 Operating System Concepts Process Termination Normal Termination:  Process executes last statement and asks the operating system to delete it (exit).  Output data from child to parent (via wait).  Process’ resources are deallocated by operating system.

16 Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.16 Operating System Concepts Other Modes of Termination Other modes of termination: Parent may terminate execution of children processes (abort).  Child has exceeded allocated resources.  Task assigned to child is no longer required.  Parent is exiting.  Operating system may not allow child to continue if its parent terminates.  Cascading termination.  In UNIX--if the parent is terminated, the child is adopted by INIT.


Download ppt "Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, 2005 4.1 Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch."

Similar presentations


Ads by Google