Presentation is loading. Please wait.

Presentation is loading. Please wait.

Process Concept An operating system executes a variety of programs

Similar presentations


Presentation on theme: "Process Concept An operating system executes a variety of programs"— Presentation transcript:

1 Process Concept An operating system executes a variety of programs
Batch system – jobs Time-shared systems – user programs or tasks Process – a program in execution A process includes: Text segment Data segment Stack segment Program counter Operating System Concepts

2 Process State As a process executes, it changes state
new: The process is being created. running: Instructions are being executed on the CPU. waiting: The process is waiting for some event to occur. ready: The process is waiting for the CPU. terminated: The process has finished execution. Operating System Concepts

3 Process Control Block (PCB)
Information associated with each process. Process state Program counter CPU register values CPU scheduling information Memory-management information Accounting information I/O status information Operating System Concepts

4 Process Queues Job queue – set of all PCBs 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 a resource, e.g., an I/O device. PCBs migrate between the various queues. Operating System Concepts

5 Ready Queue And Various I/O Device Queues
Operating System Concepts

6 Context Switch When the CPU switches to another process, the system must Switch to kernel mode Save the state of the old process Deal with the interrupt Load the saved state for the new process. Hardware (and possibly OS) saves the state of the old process The scheduler selects the new process The dispatcher loads the new process Set the PC Switch to user mode Context-switch time is overhead; the system does no useful work while switching Time dependent on hardware support. Operating System Concepts

7 CPU Switch From Process to Process
Illustrate where scheduling takes place Illustrate what the dispatcher does Operating System Concepts

8 Process Creation Parent process create children processes, which, in turn create other processes, forming a tree of processes. Address space (one of) Child duplicate of parent. Child has a program loaded into it. Execution (one of) Parent and child execute concurrently Parent waits until child terminates Resource sharing (one of) Parent and children share all resources. Children share subset of parent’s resources. Parent and child share no resources. Operating System Concepts

9 Process Termination Process executes last statement and tells the OS
Output status from child to parent Process’ resources are (eventually) deallocated by the operating system Parent may terminate execution of children processes Child has exceeded allocated resources. Task assigned to child is no longer required. Parent is exiting With cascading termination, the operating system does not allow child to continue if its parent terminates Operating System Concepts

10 UNIX PCBs Operating System Concepts

11 UNIX Shell Operating System Concepts

12 Threads A thread (or lightweight process) is a basic unit of CPU utilization; it consists of: Program counter Register set Stack space A thread shares with its peer threads its: Code segment Data segment Operating-system resources A traditional or heavyweight process is equal to a task with one thread. Operating System Concepts

13 Single and Multithreaded Processes
Operating System Concepts

14 Thread Implementations
User-level threads library POSIX Pthreads Mach C-threads Solaris threads Kernel Threads Windows 95/98/NT/2000 Solaris Linux Operating System Concepts

15 Many-to-One Many user-level threads mapped to single kernel thread.
Used on systems that do not support kernel threads. Operating System Concepts

16 One-to-One Each user-level thread maps to kernel thread. Examples
Windows 95/98/NT/2000 OS/2 LinuxThreads Operating System Concepts

17 Many-to-Many Model Allows many user level threads to be mapped to many kernel threads. Allows the operating system to create a sufficient number of kernel threads. Solaris 2 Windows NT/2000 with the ThreadFiber package Operating System Concepts

18 Pthreads A POSIX standard (IEEE c) API for thread creation and synchronization. API specifies behavior of the thread library, implementation is up to development of the library. Common in UNIX operating systems. Operating System Concepts

19 Benefits Responsiveness Resource Sharing Economy
In a multiple threaded task, while one thread is blocked and waiting, a second thread in the same task can run. Kernel level threads provide a mechanism that allows sequential processes to make blocking system calls while also achieving parallelism. Resource Sharing Economy Utilization of MP Architectures Operating System Concepts


Download ppt "Process Concept An operating system executes a variety of programs"

Similar presentations


Ads by Google