processes
play

Processes Basic Concepts Context Switching Process Queues - PDF document

CSC 4103 - Operating Systems Roadmap Spring 2008 Virtual Machines Processes Lecture - III Processes Basic Concepts Context Switching Process Queues Process Scheduling Process Termination Tevfik Ko ar


  1. CSC 4103 - Operating Systems Roadmap Spring 2008 • Virtual Machines • Processes Lecture - III Processes – Basic Concepts – Context Switching – Process Queues – Process Scheduling – Process Termination Tevfik Ko � ar Louisiana State University January 22 nd , 2008 1 2 Virtual Machines Virtual Machines (Cont.) • A virtual machine takes the layered approach • The resources of the physical computer are shared to to its logical conclusion. It treats hardware create the virtual machines and the operating system kernel as though – CPU scheduling can create the appearance that users have they were all hardware their own processor • A virtual machine provides an interface – Spooling and a file system can provide virtual card readers and identical to the underlying bare hardware virtual line printers • The virtual machine creates the illusion of – A normal user time-sharing terminal serves as the virtual machine operator’s console multiple processes, each executing on its own processor with its own (virtual) memory 3 4 Virtual Machines (Cont.) Virtual Machines (Cont.) • The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources. • A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation. Non-virtual Machine Virtual Machine • The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine (a) Nonvirtual machine (b) Virtual machine 5 6

  2. VMware Architecture Processes 7 8 Process Concept Process Control Block (PCB) process control block • An operating system executes a Information associated with each (PCB) variety of programs: process – Batch system – jobs stack • Process state – Time-shared systems – user programs – (running, waiting..) or tasks data • Program counter • Process – a program in execution; process execution must progress • CPU registers in sequential fashion • CPU scheduling information • A process includes: program – (i.e. process priority) – program counter code • Memory-management – stack: temporary data information – (i.e. page & segment tables) • Accounting information Process in Memory • I/O status information 9 10 Process State Context Switch • As a process executes, it changes state – new : The process is being created • When CPU switches to another process, the system – ready : The process is waiting to be assigned to a process must save the state of the old process and load the – running : Instructions are being executed saved state for the new process – waiting : The process is waiting for some event to occur • Context-switch time is overhead; the system does no – terminated : The process has finished execution useful work while switching • Switching time is dependent on hardware support 11 12

  3. CPU Switch From Process to Process Process Scheduling Queues • Job queue – set of all jobs 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 • Processes migrate among the various queues 13 14 Ready Queue And Various I/O Device Queues Representation of Process Scheduling 15 16 Schedulers Schedulers (Cont.) • Short-term scheduler is invoked very frequently • Long-term scheduler (or job scheduler) – (milliseconds) � (must be fast) selects which processes should be brought into • Long-term scheduler is invoked very infrequently the ready queue (seconds, minutes) � (may be slow) • Short-term scheduler (or CPU scheduler) – • The long-term scheduler controls the degree of selects which process should be executed next multiprogramming and allocates CPU • Processes can be described as either: – I/O-bound process – spends more time doing I/O than computations, many short CPU bursts – CPU-bound process – spends more time doing computations; few very long CPU bursts � long-term schedulers need to make careful decision 17 18

  4. Addition of Medium Term Scheduling Process Creation • In time-sharing systems: remove processes from • Parent process create children processes, which, in turn memory “temporarily” to reduce degree of create other processes, forming a tree of processes multiprogramming. • Resource sharing • Later, these processes are resumed � Swapping – Parent and children share all resources – Children share subset of parent’s resources – Parent and child share no resources • Execution – Parent and children execute concurrently – Parent waits until children terminate 19 20 A tree of processes on a typical Solaris Process Creation (Cont.) • sched: root process for OS • Address space • pageout: manages memory – Child duplicate of parent • fsflush: manages file system – Child has a program loaded into it • init: root for user processes • UNIX examples • inetd: Networking – fork system call creates new process • dtlogin: user login screen – exec system call used after a fork to replace the process’ • … memory space with a new program � Unique process id’s 21 22 C Program Forking Separate Process Process Termination int main() { • Process executes last statement and asks the operating Pid_t pid; system to delete it ( exit ) � /* fork another process */ – Output data from child to parent (via wait ) � pid = fork(); – Process’ resources are deallocated by operating system � if (pid < 0) { /* error occurred */ • Parent may terminate execution of children processes � � fprintf(stderr, "Fork Failed"); ( abort ) � � exit(-1); – Child has exceeded allocated resources � } – Task assigned to child is no longer required � else if (pid == 0) { /* child process */ – If parent is exiting � � execlp("/bin/ls", "ls", NULL); • Some operating system do not allow child to continue if its parent � } terminates � else { /* parent process */ – All children terminated - cascading termination � � /* parent will wait for the child to complete */ 23 24

  5. Cooperating Processes Summary • Virtual Machines • Independent process cannot affect or be affected by Hmm. • Processes the execution of another process – Basic Concepts . • Cooperating process can affect or be affected by the – Context Switching execution of another process – Process Queues • Advantages of process cooperation – Process Scheduling – Process Termination – Information sharing – Computation speed-up – Modularity – Convenience • Next Lecture: Threads • Reading Assignment: Chapter 3 from Silberschatz. • HW 1 will be out next class, due 1 week 25 26 Acknowledgements • “Operating Systems Concepts” book and supplementary material by A. Silberschatz, P . Galvin and G. Gagne • “Operating Systems: Internals and Design Principles” book and supplementary material by W. Stallings • “Modern Operating Systems” book and supplementary material by A. Tanenbaum • R. Doursat and M. Yuksel from UNR 27

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend