Operating system applications ppt

Principles of Operating Systems and history of operating systems ppt and operating system design issues ppt
Dr.SamuelHunt Profile Pic
Dr.SamuelHunt,United Arab Emirates,Teacher
Published Date:21-07-2017
Your Website URL(Optional)
Principles of Operating Systems Lecture 3-5 - Processes and Threads Ardalan Amiri Sani (ardalanuci.edu) lecture slides contains some content adapted from : previous slides by Prof. Nalini Venkatasubramanian, http://www-inst.eecs.berkeley.edu/cs162/ Copyright © 2010 UCB, and course text slides © Silberschatz 1Outline ■ Process Concept ■ Process Scheduling ■ Operations on Processes ■ Cooperating Processes ■ Threads ■ Interprocess Communication 2Process Concept ■ An operating system executes a variety of programs ■ batch systems - jobs ■ time-shared systems - user programs or tasks ■ job and program used interchangeably ■ Process - a program in execution (with limited rights) ■ process execution proceeds in a sequential fashion ■ A process contains ■ program counter, stack and data section 3Process =? Program main () main () Heap …; …; Stack A() A() A main …; …; Process Program ■ More to a process than just a program: ❑ Program is just part of the process state ❑ I run Vim on lectures.txt, you run it on homework.java – Same program, different processes ■ Less to a process than a program: ❑ A program can invoke more than one process ❑ cc/cpp starts up processes to handle different stages of the compilation process cc1, cc2, as, and ld 4Process State ■ A process changes state as it executes. admitted new terminated exit interrupt running ready Scheduler I/O or I/O or dispatch event event wait completion waiting 5Process States ■ New - The process is being created. ■ Running - Instructions are being executed. ■ Waiting - Waiting for some event to occur. ■ Ready - Waiting to be assigned to a processor. ■ Terminated - Process has finished execution. 6Process Control Block ■ Contains information associated with each process ■ Process State - e.g. new, ready, running etc. ■ Process Number – Process ID ■ Program Counter - address of next instruction to be executed ■ CPU registers - general purpose registers, stack pointer etc. ■ CPU scheduling information - process priority ■ Memory Management information - base/limit information ■ Accounting information - time Process limits, I/O resources Control ❑ I/O Status information - list of I/O devices allocated Block 7Process Scheduling Process (PCB) moves from queue to queue When does it move? Where? A scheduling decision 8Process Scheduling 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. ■ Process migration between the various queues. ■ Queue Structures - typically linked list, circular list etc. 9Process Queues Device Queue Ready Queue 10Enabling Concurrency and Protection: Multiplex processes ■ Only one process (PCB) active at a time ❑ Current state of process held in PCB: ■ “snapshot” of the execution and protection environment ❑ Process needs CPU, resources ■ Give out CPU time to different processes (Scheduling): ❑ Only one process “running” at a time ❑ Give more time to important processes ■ Give pieces of resources to different processes (Protection): ❑ Controlled access to non-CPU resources ■ E.g. Memory Mapping: Give each process their own address space Process Control 11 BlockEnabling Concurrency: Context Switch ■ Task that switches CPU from one process to another process ❑ the CPU must save the PCB state of the old process and load the saved PCB state of the new process. ■ Context-switch time is overhead ❑ System does no useful work while switching ❑ Overhead sets minimum practical switching time; can become a bottleneck ■ Time for context switch is dependent on hardware support ( 1- 1000 microseconds). 12CPU Switch From Process to Process ■ Code executed in kernel above is overhead ❑ Overhead sets minimum practical switching time 13Schedulers ■ Long-term scheduler (or job scheduler) - ❑ selects which processes should be brought into the ready queue. ❑ invoked very infrequently (seconds, minutes); may be slow. ❑ controls the degree of multiprogramming ■ Short term scheduler (or CPU scheduler) - ❑ selects which process should execute next and allocates CPU. ❑ invoked very frequently (milliseconds) - must be very fast ■ Medium Term Scheduler ❑ swaps out process temporarily ❑ balances load for better throughput 14Medium Term (Time-sharing) Scheduler 15Process Profiles ■ I/O bound process - ❑ spends more time in I/O, short CPU bursts, CPU underutilized. ■ CPU bound process - ❑ spends more time doing computations; few very long CPU bursts, I/O underutilized. ■ The right job mix: ❑ Long term scheduler - admits jobs to keep load balanced between I/O and CPU bound processes ❑ Medium term scheduler – ensures the right mix (by sometimes swapping out jobs and resuming them later) 16Process Creation ■ Processes are created and deleted dynamically ■ Process which creates another process is called a parent process; the created process is called a child process. ■ Result is a tree of processes ■ e.g. UNIX - processes have dependencies and form a hierarchy. ■ Resources required when creating process ■ CPU time, files, memory, I/O devices etc. 17UNIX Process Hierarchy 18What does it take to create a process? ■ Must construct new PCB ❑ Inexpensive ■ Must set up new page tables for address space ❑ More expensive ■ Copy data from parent process? (Unix fork() ) ❑ Semantics of Unix fork() are that the child process gets a complete copy of the parent memory and I/O state ❑ Originally very expensive ❑ Much less expensive with “copy on write” ■ Copy I/O state (file handles, etc) ❑ Medium expense 19Process Creation ■ Resource sharing ❑ Parent and children share all resources. ❑ Children share subset of parent’s resources - prevents many processes from overloading the system. ❑ Parent and children share no resources. ■ Execution ❑ Parent and child execute concurrently. ❑ Parent waits until child has terminated. ■ Address Space ❑ Child process is duplicate of parent process. ❑ Child process has a program loaded into it. 20

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.