1 / 58

Course Overview Principles of Operating Systems

Learn about the fundamental unit of operation in an operating system - processes. Understand how processes are used to run programs, their requirements, mechanisms, and principles of cooperation. Acquire the necessary terminology related to processes and their execution.

plante
Download Presentation

Course Overview Principles of Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction Computer System Structures Operating System Structures Processes Process Synchronization Deadlocks CPU Scheduling Memory Management Virtual Memory File Management Security Networking Distributed Systems Case Studies Conclusions Course OverviewPrinciples of Operating Systems

  2. Motivation Objectives Processes and Programs Process States Operations on Processes Operating System Control Structures Process Control Block Processes and Threads Process Scheduling Cooperating Processes Interprocess Communication Important Concepts and Terms Chapter Summary Chapter Overview Processes

  3. Motivation • applications can only run through the use of processes • processes are the fundamental unit of operation in an operating system • most components of the operating systems provide services for the execution of processes • processes require resources for their execution

  4. Objectives • understand the use of processes for running programs • know the requirements and mechanisms for the execution of processes • understand the principles of cooperation between processes • acquire the terminology related to processes and their execution

  5. Processes and Programs • both terms are used to describe the activities performed by a computer • program refers to the instructions as specified by the programmer • process refers to the activities performed by the computer as the instructions of a program are executed

  6. Terminology • program • application • job • task • process • thread

  7. Program • set of instructions specifying the activities necessary to accomplish a task • frequently used in a broad sense • static: usually doesn’t change unless modified by the programmer

  8. Application • program used for a specific task • often used for programs available to the user, in contrast to programs used internally by the OS

  9. Job • used to describe the unit of work in a batch system • frequently used synonymously to process

  10. Task • unit of work from the user’s perspective in a time-sharing or multitasking system • often corresponds to an application program • may comprise several processes

  11. Process • program in execution • unit of work from the OS perspective, in particular with respect to resource ownership • dynamic: changes its state over time (during execution) • may consist of several threads

  12. Thread • smallest dispatchable unit in the OS • several threads are usually grouped into a process, and can cooperate on a task • sometimes also called lightweight processes

  13. Execution of Programs • multiprogramming • multiprocessing • multitasking • multithreading

  14. Example Processes • consider three processes • process A executes 100 instructions, reads two blocks from hard disk, and executes another 100 instructions • process B reads one block from hard disk, executes 100 instructions, and writes one block to disk • process C executes 1000 instructions, and writes two blocks to disk • timing • 10 ns per CPU instruction (100 MHertz clock frequency) • 10 ms average transfer time per block between hard disk and memory

  15. overall execution time for single-programming20,002,000 + 20,001,000 + 20,010,000 ns = 60,013,000 ns CPU is idle for 60,000,000 ns CPU CPU CPU CPU Example Single-Programming 1,000 ns A B C 10,000 ns 1,000 ns 1,000 ns 1,000 ns I/O I/O I/O I/O 20 ,000 ,000 ns 10 ,000 ,000 ns 10 ,000 ,000 ns 20 ,000 ,000 ns

  16. Multiprogramming • several programs are simultaneously under execution • they are between start and finish • simultaneously refers to a human time-scale (seconds) • at the CPU time scale, only one process is handled by the CPU (single processor systems) • creates logical parallelism • mainly used in batch systems to increase CPU utilization

  17. logical parallelism: all three programs are run simultaneously problem: only one CPU available 1,000 ns 1,000 ns I/O A CPU A CPU A 20 ,000 ,000 ns 1,000 ns I/O B I/O B CPU B 10 ,000 ,000 ns 10 ,000 ,000 ns 10,000 ns CPU C I/O C 20 ,000 ,000 ns Example Multiprogramming 1,000 ns 1,000 ns A B C

  18. solution: multiplexing of the CPU by switching between processes I/O operations concurrently with CPU operations problem: more complex requires process management Proc. A Proc. C Proc. B Proc. A I/O B I/O B I/O C Example Multiprogramming 1,000 ns 1,000 ns Attention: Dimensions not to scale 10,000 ns 1,000 ns 1,000 ns 1,000 ns I/O A 10 ,000 ,000 ns 20 ,000 ,000 ns 20 ,000 ,000 ns 10 ,000 ,000 ns

  19. Multiprocessing • several processes run simultaneously on different CPUs • creates physical parallelism • advantages • short overall execution time • problems • CPUs might have to sharememory, I/O devices • low CPU utilization • communication between processes • process allocation and load balancing

  20. physical parallelism: all three programs are run simultaneously on three different CPUs 1,000 ns 1,000 ns I/O A Proc. A Proc. A 20 ,000 ,000 ns 1,000 ns I/O B I/O B Proc. B 10 ,000 ,000 ns 10 ,000 ,000 ns 10,000 ns Proc. C I/O C 20 ,000 ,000 ns Example Multiprocessing 1,000 ns 1,000 ns CPU 1 CPU 2 CPU 3

  21. Multitasking • conceptually similar to multiprogramming: better CPU utilization by switching between processes • more frequent switching so that users can interact with the program • necessary for time-sharing system

  22. Multithreading • within one single process, multiple threads of execution are used • independent activities within one program or application can be performed in parallel • either on different CPUs, or via switching between threads • decreases the overhead of switching between processes

  23. Process States • over their existence, processes can be in different states • newly created • ready to run on the CPU • running on the CPU • blocked because it is waiting for an event or an I/O operation • terminated

  24. Process State Diagram new terminated admission release dispatch ready running time-out I/O or event completion I/O or event wait blocked

  25. Operations on Processes • process creation • new batch job, user login, OS service, child process • process termination • normal completion, time limit exceeded, resources unavailable, protection error, calculation error, invalid instruction, OS intervention, parent termination, parent request • context switch • execution of one process is stopped, and another process continues • change of process state • implicit via context switch, explicit by the OS

  26. Operating System Control Structures • used to maintain information about important entities and activities in the computer system • management of processes and resources • information about the status of processes and devices • usually stored in tables, possibly with pointers to further information • cross-references must exist between different tables • the OS must know the basic configuration of the computer system

  27. Memory Tables Process 1 Memory Device Tables Devices Files File Tables Processes Process 1 Process n Process 2 Process 3 Process Tables . . . Process n OS Control Structures Process Image Process Image [adapted from Stallings 98]

  28. Memory Tables • used to keep track of memory usage • allocation of main memory to processes • OS and user processes • allocation of secondary memory to processes • swap space or virtual memory • protection attributes of memory segments • access permissions

  29. I/O Tables • used for the management of I/O devices • allocation of devices to processes • status of devices • available, allocated to a process • I/O operation in progress • memory segment involved in the I/O operation • in some operating systems, I/O devices are integrated into the file system

  30. File Tables • used for the management of files and directories • access information for files • name, path • location on secondary memory • file status information • open, closed • processes using the file

  31. Process Tables • used for the management of processes • location of the process • main memory, secondary storage • process attributes • process identification (pid) • unique number, often used as index into the process table • parent process, affiliated user, children

  32. Process Image • user program • program to be executed • user data • program data, user stack, modifiable parts of the program • system stack • parameters, procedure call and return addresses • at least one per process • process control block • essential process data needed by the OS

  33. Process Control Block • process identification • processor state information • process control information

  34. Process Identification • process id, parent process, user id • used by the operating system for all activities involving processes • process management, main memory, I/O devices, interprocess communication • cross-reference to between process and other OS tables

  35. Processor State Information • user registers • registers available to the user program • system registers • used for control and status information • program counter, condition codes (e.g. division by zero, overflow), status register (interrupt enabled, system/user mode) • stack pointers • points to the top of system stacks • these stacks contain parameters, procedure call and return addresses, and execution-related data

  36. Process Control Information • scheduling and state information • process state, priority, time in ready queue, etc. • process relations • links to other processes (waiting queues, parent/child)interprocess communications • flags, signals, messages, shared memory • process privileges • memory access, instruction execution, resources • memory management • pointers to memory segments used by the process • resources • ownership and utilization of resources

  37. Processes and Address Spaces Process 1 Process 2 Process n Process Identification Process Identification Process Identification Process Control Block Process State Information Process State Information Process State Information Process Control Information Process Control Information Process Control Information System Stack System Stack System Stack User Stack User Stack User Stack User Address Space User Address Space User Address Space Shared Address Space Shared Address Space [adapted from Stallings 98]

  38. several processes need to be accomodated OS has its own memory section simplified view larger number of processes processes do not occupy one single section in memory, but several smaller ones (non-contiguous allocation) not the whole process image is always present in memory (virtual memory) Process 2 Main Memory Process n Process 1 Operating System Processes in Memory

  39. Process Scheduling • objective: efficient allocation of CPU processing time to processes • in uniprocessor systems: multiplexing of the CPU between processes • in multiprocessor systems: allocation of processes to CPUs, load balancing across CPUs, multiplexing if there are more processes than processors • very important in multiprogramming and multitasking • maximization of CPU utilization • interaction between programs and users

  40. Schedulers • job scheduler • long-term scheduling • medium-term scheduler • not used in all systems • CPU scheduler • short-term scheduling

  41. Job Scheduler • manages processes that can’t be executed immediately • not enough memory available • CPU load too high • processes waiting for I/O are kept separately • controls the degree of multiprogramming • number of processes in main memory • is not invoked too frequently • mainly when processes enter or leave the system

  42. Medium-Term Scheduler • processes are temporarily moved out of main memory to secondary storage (“swapping”) • memory space restrictions • to improve the process mix (balance between CPU-intensive and I/O-intensive processes) • determines which processes to swap out and in

  43. CPU scheduler • manages processes in the ready queue • processes have all the resources they need, except for CPU time • is invoked very frequently • a process requests an I/O operation • time slice of a process is over • interrupt or trap • OS intervention • must be very fast to reduce overhead

  44. Scheduling Queues • first-in, first-out (FIFO) data structures used to administer the scheduling of processes • types of queues • job queue: newly created processes not yet ready for execution • ready queue: processes in main memory and ready for execution • device queue: processes waiting for a particular device • event queue: processes waiting for an event • queuing diagrams display the interdependencies • can be derived from the process state diagram

  45. Process State Diagram dispatch admission release not running running pause Queue Two-State Process Model Queuing Diagram release dispatch admission CPU pause [adapted from Stallings 98]

  46. new terminated admission release dispatch ready running time-out I/O or event completion I/O or event wait blocked Five-State Process Model

  47. Job Queue Event 1 Queue Event 2 Queue Event n Queue Queuing Diagram Five-State admission release forward dispatch Ready Queue CPU time-out I/O or event completion I/O or event wait . . .

  48. Context Switch • the execution of one process on the CPU is halted, and the CPU continues with another • information about the old process must be saved • saved information about the new process must be restored • highly dependent on hardware support • multiple sets of registers • special instructions, e.g. to load and store registers • context switching time is pure overhead • no productive work is done • should be kept as low as possible

  49. Threads • reduce the overhead of context switching • only essential information about individual threads is saved for a thread switch • program counter, register set, stack • other information is shared by a group of threads within a process or task • code section, data section, resources • enable asynchronous and distributed processing • support modular programs • also sometimes referred to as lightweight processes

  50. Types of Threads • user-level threads • managed by the user process instead of the OS • uses user-level libraries instead of system calls • often more efficient since the OS is not involved • can be difficult to program • kernel-level threads • scheduled by the OS • threads may be distributed over several processors

More Related