30326851 -operating-system-unit-1-ppt


Published on


Published in: Technology
1 Comment
1 Like
  • not effective
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

30326851 -operating-system-unit-1-ppt

  2. 2. What is an Operating System?  A program that acts as an intermediary between a user of a computer and the computer hardware.  Operating system goals:  Execute user programs and make solving user problems easier.  Make the computer system convenient to use.  Use the computer hardware in an efficient manner. CS1252-OPERATING SYSTEM UNIT I 2
  3. 3. Computer System Components1. Hardware – provides basic computing resources (CPU, memory, I/O devices).2. Operating system – controls and coordinates the use of the hardware among the various application programs for the various users.3. Applications programs – define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs).4. Users (people, machines, other computers). CS1252-OPERATING SYSTEM UNIT I 3
  4. 4. Abstract View of SystemComponents CS1252-OPERATING SYSTEM UNIT I 4
  5. 5. Operating System Definitions  Resource allocator – manages and allocates resources.  Control program – controls the execution of user programs and operations of I/O devices .  Kernel – the one program running at all times (all else being application programs). CS1252-OPERATING SYSTEM UNIT I 5
  6. 6. Mainframe Systems  Reduce setup time by batching similar jobs  Automatic job sequencing – automatically transfers control from one job to another. First rudimentary operating system.  Resident monitor  initial control in monitor  control transfers to job  when job completes control transfers pack to monitor CS1252-OPERATING SYSTEM UNIT I 6
  7. 7. Memory Layout for a Simple Batch System CS1252-OPERATING SYSTEM UNIT I 7
  8. 8. Multi - programmed Batch Systems Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. CS1252-OPERATING SYSTEM UNIT I 8
  9. 9. OS Features Needed forMultiprogramming  I/O routine supplied by the system.  Memory management – the system must allocate the memory to several jobs.  CPU scheduling – the system must choose among several jobs ready to run.  Allocation of devices. CS1252-OPERATING SYSTEM UNIT I 9
  10. 10. Time-Sharing Systems–InteractiveComputing The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory). A job swapped in and out of memory to the disk. On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard. On-line system must be available for users to access data and code. CS1252-OPERATING SYSTEM UNIT I 10
  11. 11. Desktop Systems  Personal computers – computer system dedicated to a single user.  I/O devices – keyboards, mice, display screens, small printers.  User convenience and responsiveness.  Can adopt technology developed for larger operating system’ often individuals have sole use of computer and do not need advanced CPU utilization of protection features.  May run several different types of operating systems (Windows, MacOS, UNIX, Linux) CS1252-OPERATING SYSTEM UNIT I 11
  12. 12. Parallel Systems Multiprocessor systems with more than on CPU in close communication. Tightly coupled system – processors share memory and a clock; communication usually takes place through the shared memory. Advantages of parallel system:  Increased throughput  Economical  Increased reliability  graceful degradation  fail-soft systems CS1252-OPERATING SYSTEM UNIT I 12
  13. 13. Parallel Systems (Cont.)  Symmetric multiprocessing (SMP)  Each processor runs and identical copy of the operating system.  Many processes can run at once without performance deterioration.  Most modern operating systems support SMP  Asymmetric multiprocessing  Each processor is assigned a specific task; master processor schedules and allocated work to slave processors.  More common in extremely large systems CS1252-OPERATING SYSTEM UNIT I 13
  14. 14. Symmetric Multiprocessing Architecture CS1252-OPERATING SYSTEM UNIT I 14
  15. 15. Distributed Systems  Distribute the computation among several physical processors.  Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines.  Advantages of distributed systems.  Resources Sharing  Computation speed up – load sharing  Reliability  Communications CS1252-OPERATING SYSTEM UNIT I 15
  16. 16. Distributed Systems (cont)  Requires networking infrastructure.  Local area networks (LAN) or Wide area networks (WAN)  May be either client-server or peer-to-peer systems. CS1252-OPERATING SYSTEM UNIT I 16
  17. 17. General Structure of Client-Server CS1252-OPERATING SYSTEM UNIT I 17
  18. 18. Clustered Systems Clustering allows two or more systems to share storage. Provides high reliability. Asymmetric clustering: one server runs the application while other servers standby. Symmetric clustering: all N hosts are running the application. CS1252-OPERATING SYSTEM UNIT I 18
  19. 19. Real-Time Systems  Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems.  Well-defined fixed-time constraints.  Real-Time systems may be either hard or soft real- time. CS1252-OPERATING SYSTEM UNIT I 19
  20. 20. Real-Time Systems (Cont.)  Hard real-time:  Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM)  Conflicts with time-sharing systems, not supported by general-purpose operating systems.  Soft real-time  Limited utility in industrial control of robotics  Useful in applications (multimedia, virtual reality) requiring advanced operating-system features. CS1252-OPERATING SYSTEM UNIT I 20
  21. 21. Handheld Systems Personal Digital Assistants (PDAs) Cellular telephones Issues:  Limited memory  Slow processors  Small display screens. CS1252-OPERATING SYSTEM UNIT I 21
  22. 22. Hardware Protection Dual-Mode Operation I/O Protection Memory Protection CPU Protection CS1252-OPERATING SYSTEM UNIT I 22
  23. 23. Dual-Mode Operation Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly. Provide hardware support to differentiate between at least two modes of operations. 1. User mode – execution done on behalf of a user. 2. Monitor mode (also kernel mode or system mode) – execution done on behalf of operating system. CS1252-OPERATING SYSTEM UNIT I 23
  24. 24. Dual-Mode Operation (Cont.)  Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1).  When an interrupt or fault occurs hardware switches to monitor mode.Interrupt/fault monitor user set user mode Privileged instructions can be issued only in monitor mode. CS1252-OPERATING SYSTEM UNIT I 24
  25. 25. I/O Protection All I/O instructions are privileged instructions. Must ensure that a user program could never gain control of the computer in monitor mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector). CS1252-OPERATING SYSTEM UNIT I 25
  26. 26. Use of A System Call to Perform I/O CS1252-OPERATING SYSTEM UNIT I 26
  27. 27. Memory Protection Must provide memory protection at least for the interrupt vector and the interrupt service routines. In order to have memory protection, add two registers that determine the range of legal addresses a program may access:  Base register – holds the smallest legal physical memory address.  Limit register – contains the size of the range Memory outside the defined range is protected. CS1252-OPERATING SYSTEM UNIT I 27
  28. 28. Use of A Base and Limit Register CS1252-OPERATING SYSTEM UNIT I 28
  29. 29. Hardware Address Protection CS1252-OPERATING SYSTEM UNIT I 29
  30. 30. Hardware Protection When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory. The load instructions for the base and limit registers are privileged instructions. CS1252-OPERATING SYSTEM UNIT I 30
  31. 31. CPU Protection Timer – interrupts computer after specified period to ensure operating system maintains control.  Timer is decremented every clock tick.  When timer reaches the value 0, an interrupt occurs. Timer commonly used to implement time sharing. Time also used to compute the current time. Load-timer is a privileged instruction. CS1252-OPERATING SYSTEM UNIT I 31
  32. 32. Common System Components  Process Management  Main Memory Management  File Management  I/O System Management  Secondary Management  Networking  Protection System  Command-Interpreter System CS1252-OPERATING SYSTEM UNIT I 32
  33. 33. Contd… PROCESS MANAGEMENT  A process is a program in execution: (A program is passive, a process active.)  A process has resources (CPU time, files) and attributes that must be managed.  Management of processes includes: • Process Scheduling (priority, time management, . . . ) • Creation/termination • Block/Unblock (suspension/resumption ) • Synchronization • Communication • Deadlock handling • Debugging CS1252-OPERATING SYSTEM UNIT I 33
  34. 34. Contd… MAIN MEMORY MANAGEMENT • Allocation/de-allocation for processes, files, I/O. • Maintenance of several processes at a time • Keep track of whos using what memory • Movement of process memory to/from secondary storage. SECONDARY STORAGE MANAGEMENT • Disks, tapes, optical, ... • Free space management ( paging/swapping ) • Storage allocation ( what data goes where on disk ) CS1252-OPERATING SYSTEM UNIT I 34 • Disk scheduling
  35. 35.  DEVICE MANAGEMENT • Buffer caching system • Generic device driver code • Drivers for each device - translate read/write requests into disk position commands. FILE MANAGEMENT Keep track of whats on secondary storage.  file == logical entity,  disk == physical entity • Map logical file locations onto physical disk locations. • May involve management of a file structure ( directory hierarchy ) · Does file/directory creation/deletion · File manipulation ( rename, move, append ) · File backup CS1252-OPERATING SYSTEM UNIT I 35
  36. 36.  PROTECTION • Of files, memory, CPU, etc. • Means controlling of access • Depends on the attributes of the file and user COMMUNICATION • Communication system between distributed processors. • Getting information about files/processes/etc. on a remote machine. • Can use either a message passing or a shared memory model. CS1252-OPERATING SYSTEM UNIT I 36
  37. 37. Operating System Services  Program execution – system capability to load a program into memory and to run it.  I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O.  File-system manipulation – program capability to read, write, create, and delete files.  Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing.  Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. These are discussed in detail below CS1252-OPERATING SYSTEM UNIT I 37
  38. 38. Operating System Services One set of operating-system services provides functions that are helpful to the user:  User interface - Almost all operating systems have a user interface (UI)  Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch  Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)  I/O operations - A running program may require I/O, which may involve a file or an I/O device.  File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. CS1252-OPERATING SYSTEM UNIT I 38
  39. 39. Operating System Services (Cont.)  One set of operating-system services provides functions that are helpful to the user (Cont):  Communications – Processes may exchange information, on the same computer or between computers over a network  Communications may be via shared memory or through message passing (packets moved by the OS)  Error detection – OS needs to be constantly aware of possible errors  May occur in the CPU and memory hardware, in I/O devices, in user program  For each type of error, OS should take the appropriate action to ensure correct and consistent computing  Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system CS1252-OPERATING SYSTEM UNIT I 39
  40. 40. Operating System Services (Cont.)  Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing  Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them  Many types of resources - Some (such as CPU cycles,mainmemory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code.  Accounting - To keep track of which users use how much and what kinds of computer resources  Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other  Protection involves ensuring that all access to system resources is controlled  Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts  If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link. CS1252-OPERATING SYSTEM UNIT I 40
  41. 41. User Operating System Interface -CLI CLI allows direct command entry  Sometimes implemented in kernel, sometimes by systems program  Sometimes multiple flavors implemented – shells  Primarily fetches a command from user and executes it  Sometimes commands built-in, sometimes just names of programs  If the latter, adding new features doesn’t require shell modification CS1252-OPERATING SYSTEM UNIT I 41
  42. 42. User Operating System Interface -GUI User-friendly desktop metaphor interface  Usually mouse, keyboard, and monitor  Icons represent files, programs, actions, etc  Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder)  Invented at Xerox PARC Many systems now include both CLI and GUI interfaces  Microsoft Windows is GUI with CLI “command” shell  Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available  Solaris is CLI with optional GUI interfaces (Java Desktop, KDE) CS1252-OPERATING SYSTEM UNIT I 42
  43. 43. Additional Operating System FunctionsAdditional functions exist not for helping the user, but rather forensuring efficient system operations. • Resource allocation – allocating resources to multiple users or multiple jobs running at the same time. • Accounting – keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics. • Protection – ensuring that all access to system resources is controlled. CS1252-OPERATING SYSTEM UNIT I 43
  44. 44. System Calls  System calls provide the interface between a running program and the operating system.  Generally available as assembly-language instructions.  Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C, C++)  Three general methods are used to pass parameters between a running program and the operating system.  Pass parameters in registers.  Store the parameters in a table in memory, and the table address is passed as a parameter in a register.  Push (store) the parameters onto the stack by the program, and pop off the stack by operating system. CS1252-OPERATING SYSTEM UNIT I 44
  45. 45. Example of System Calls System call sequence to copy the contents of one file to another file CS1252-OPERATING SYSTEM UNIT I 45
  46. 46. Example of Standard API Consider the ReadFile() function in the Win32 API—a function for reading from a file A description of the parameters passed to ReadFile()  HANDLE file—the file to be read  LPVOID buffer—a buffer where the data will be read into and written from  DWORD bytesToRead—the number of bytes to be read into the buffer  LPDWORD bytesRead—the number of bytes read during the last read  LPOVERLAPPED ovl—indicates if overlappedI I/O is being used CS1252-OPERATING SYSTEM UNIT 46
  47. 47. System Call Implementation Typically, a number associated with each system call  System-call interface maintains a table indexed according to these numbers The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented  Just needs to obey API and understand what OS will do as a result call  Most details of OS interface hidden from programmer by API  Managed by run-time support library (set of functions built into libraries included with compiler) CS1252-OPERATING SYSTEM UNIT I 47
  48. 48. API – System Call – OS Relationship CS1252-OPERATING SYSTEM UNIT I 48
  49. 49. Standard C Library Example  C program invoking printf() library call, which calls write() system call CS1252-OPERATING SYSTEM UNIT I 49
  50. 50. System Call Parameter Passing Often, more information is required than simply identity of desired system call  Exact type and amount of information vary according to OS and call Three general methods used to pass parameters to the OS  Simplest: pass the parameters in registers  In some cases, may be more parameters than registers  Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register  This approach taken by Linux and Solaris  Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system  Block and stack methods do not limit the number or length of parameters being passed CS1252-OPERATING SYSTEM UNIT I 50
  51. 51. Passing of Parameters As A Table CS1252-OPERATING SYSTEM UNIT I 51
  52. 52. Types of System Calls Process control File management Device management Information maintenance Communications CS1252-OPERATING SYSTEM UNIT I 52
  53. 53. MS-DOS Execution At System Start-up Running a Program CS1252-OPERATING SYSTEM UNIT I 53
  54. 54. UNIX Running Multiple Programs CS1252-OPERATING SYSTEM UNIT I 54
  55. 55. Communication Models  Communication may take place using either message passing or shared memory. Msg Passing Shared Memory CS1252-OPERATING SYSTEM UNIT I 55
  56. 56. System Programs  System programs provide a convenient environment for program development and execution. The can be divided into:  File manipulation  Status information  File modification  Programming language support  Program loading and execution  Communications  Application programs  Most users’ view of the operation system is defined by system programs, not the actual system calls. This is told in detail as below CS1252-OPERATING SYSTEM UNIT I 56
  57. 57. System Programs Provide a convenient environment for program development and execution  Some of them are simply user interfaces to system calls; others are considerably more complex File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories Status information  Some ask the system for info - date, time, amount of available memory, disk space, number of users  Others provide detailed performance, logging, and debugging information  Typically, these programs format and print the output to the terminal or other output devices  Some systems implement a registry - used to store and retrieve configuration information CS1252-OPERATING SYSTEM UNIT I 57
  58. 58. System Programs (cont’d) File modification  Text editors to create and modify files  Special commands to search contents of files or perform transformations of the text Programming-language support - Compilers, assemblers, debuggers and interpreters sometimes provided Program loading and execution- Absolute loaders, relocatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language Communications - Provide the mechanism for creating virtual connections among processes, users, and computer systems  Allow users to send messages to one another’s screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another CS1252-OPERATING SYSTEM UNIT I 58
  59. 59. Process Concept  An operating system executes a variety of programs:  Batch system – jobs  Time-shared systems – user programs or tasks  Textbook uses the terms job and process almost interchangeably.  Process – a program in execution; process execution must progress in sequential fashion.  A process includes:  program counter  stack  data section CS1252-OPERATING SYSTEM UNIT I 59
  60. 60. Process State  As a process executes, it changes state  new: The process is being created.  running: Instructions are being executed.  waiting: The process is waiting for some event to occur.  ready: The process is waiting to be assigned to a process.  terminated: The process has finished execution. CS1252-OPERATING SYSTEM UNIT I 60
  61. 61. Diagram of Process State CS1252-OPERATING SYSTEM UNIT I 61
  62. 62. Process Control Block (PCB) Information associated with each process.  Process state  Program counter  CPU registers  CPU scheduling information  Memory-management information  Accounting information  I/O status information CS1252-OPERATING SYSTEM UNIT I 62
  63. 63. Process Control Block (PCB) CS1252-OPERATING SYSTEM UNIT I 63
  64. 64. CPU Switch From Process to Process CS1252-OPERATING SYSTEM UNIT I 64
  65. 65. Process 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. CS1252-OPERATING SYSTEM UNIT I 65
  66. 66. Ready Queue And Various I/O Device Queues CS1252-OPERATING SYSTEM UNIT I 66
  67. 67. Representation of Process Scheduling CS1252-OPERATING SYSTEM UNIT I 67
  68. 68. Schedulers Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue. Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU. CS1252-OPERATING SYSTEM UNIT I 68
  69. 69. Addition of Medium TermScheduling CS1252-OPERATING SYSTEM UNIT I 69
  70. 70. Schedulers (Cont.) Short-term scheduler is invoked very frequently (milliseconds) ⇒ (must be fast). Long-term scheduler is invoked very infrequently (seconds, minutes) ⇒ (may be slow). The long-term scheduler controls the degree of multiprogramming. 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. CS1252-OPERATING SYSTEM UNIT I 70
  71. 71. Context Switch When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. Context-switch time is overhead; the system does no useful work while switching. Time dependent on hardware support. CS1252-OPERATING SYSTEM UNIT I 71
  72. 72. Process Creation Parent process create children processes, which, in turn create other processes, forming a tree of processes. Resource sharing  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. CS1252-OPERATING SYSTEM UNIT I 72
  73. 73. Process Creation (Cont.) Address space  Child duplicate of parent.  Child has a program loaded into it. UNIX examples  fork system call creates new process  exec system call used after a fork to replace the process’ memory space with a new program. CS1252-OPERATING SYSTEM UNIT I 73
  74. 74. Processes Tree on a UNIX System CS1252-OPERATING SYSTEM UNIT I 74
  75. 75. Process Termination Process executes last statement and asks the operating system to decide it (exit).  Output data from child to parent (via wait).  Process’ resources are deallocated by operating system. 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 does not allow child to continue if its parent terminates.  Cascading termination. CS1252-OPERATING SYSTEM UNIT I 75
  76. 76. Cooperating Processes Independent process cannot affect or be affected by the execution of another process. Cooperating process can affect or be affected by the execution of another process Advantages of process cooperation  Information sharing  Computation speed-up  Modularity  Convenience CS1252-OPERATING SYSTEM UNIT I 76
  77. 77. Producer-Consumer Problem Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process.  unbounded-buffer places no practical limit on the size of the buffer.  bounded-buffer assumes that there is a fixed buffer size. CS1252-OPERATING SYSTEM UNIT I 77
  78. 78. Bounded-Buffer – Shared-Memory Solution  Shared data #define BUFFER_SIZE 10 Typedef struct { ... } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0;  Solution is correct, but can only use BUFFER_SIZE-1 elements CS1252-OPERATING SYSTEM UNIT I 78
  79. 79. Bounded-Buffer – Producer Process item nextProduced; while (1) { while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; } CS1252-OPERATING SYSTEM UNIT I 79
  80. 80. Bounded-Buffer – Consumer Process item nextConsumed; while (1) { while (in == out) ; /* do nothing */ nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; } CS1252-OPERATING SYSTEM UNIT I 80
  81. 81. Interprocess Communication (IPC) Mechanism for processes to communicate and to synchronize their actions. Message system – processes communicate with each other without resorting to shared variables. IPC facility provides two operations:  send(message) – message size fixed or variable  receive(message) If P and Q wish to communicate, they need to:  establish a communication link between them  exchange messages via send/receive Implementation of communication link  physical (e.g., shared memory, hardware bus) CS1252-OPERATING SYSTEM UNIT I 81  logical (e.g., logical properties)
  82. 82. Implementation Questions How are links established? Can a link be associated with more than two processes? How many links can there be between every pair of communicating processes? What is the capacity of a link? Is the size of a message that the link can accommodate fixed or variable? Is a link unidirectional or bi-directional? CS1252-OPERATING SYSTEM UNIT I 82
  83. 83. Direct Communication Processes must name each other explicitly:  send (P, message) – send a message to process P  receive(Q, message) – receive a message from process Q Properties of communication link  Links are established automatically.  A link is associated with exactly one pair of communicating processes.  Between each pair there exists exactly one link.  The link may be unidirectional, but is usually bi-directional. CS1252-OPERATING SYSTEM UNIT I 83
  84. 84. Indirect Communication  Messages are directed and received from mailboxes (also referred to as ports).  Each mailbox has a unique id.  Processes can communicate only if they share a mailbox.  Properties of communication link  Link established only if processes share a common mailbox  A link may be associated with many processes.  Each pair of processes may share several communication links.  Link may be unidirectional or bi-directional. CS1252-OPERATING SYSTEM UNIT I 84
  85. 85. Indirect Communication  Operations  create a new mailbox  send and receive messages through mailbox  destroy a mailbox  Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A CS1252-OPERATING SYSTEM UNIT I 85
  86. 86. Indirect Communication Mailbox sharing  P1, P2, and P3 share mailbox A.  P1, sends; P2 and P3 receive.  Who gets the message? Solutions  Allow a link to be associated with at most two processes.  Allow only one process at a time to execute a receive operation.  Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was. CS1252-OPERATING SYSTEM UNIT I 86
  87. 87. Synchronization Message passing may be either blocking or non-blocking. Blocking is considered synchronous Non-blocking is considered asynchronous send and receive primitives may be either blocking or non- blocking. CS1252-OPERATING SYSTEM UNIT I 87
  88. 88. Buffering Queue of messages attached to the link; implemented in one of three ways. 1. Zero capacity – 0 messages Sender must wait for receiver (rendezvous). 2. Bounded capacity – finite length of n messages Sender must wait if link full. 3. Unbounded capacity – infinite length Sender never waits. CS1252-OPERATING SYSTEM UNIT I 88