🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

BIT2213-Topic-1-Process-Management-Short-Semester-July-2024.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Course Overview Course Name: Operating System Course Code: BIT2213 Faculty: Business and Technology by Mr.Yudi K. Budi Course Details Process Management Key Components Process concepts This course covers essential aspects of process Concurrent processes...

Course Overview Course Name: Operating System Course Code: BIT2213 Faculty: Business and Technology by Mr.Yudi K. Budi Course Details Process Management Key Components Process concepts This course covers essential aspects of process Concurrent processes management, including how processes are conceptualized, managed concurrently, and synchronized. It also delves into Process synchronization critical issues like deadlock detection and recovery, as well Deadlock detection and recovery as fundamental scheduling concepts. Scheduling concepts Objectives Process Fundamentals Interprocess Communication To introduce the notion of a process -- a program in execution, which forms the basis of all computation To explore interprocess communication using shared memory and message passing To describe the various features of processes, including scheduling, creation and termination, and communication To describe communication in client-server systems Process Concept An operating system executes various 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 Multiple parts of a process: The program code, also called text section Current activity including program counter, processor registers Stack containing temporary data Function parameters, return addresses, local variables Data section containing global variables Heap containing memory dynamically allocated during run time Process Concept (Cont.) Program is passive entity stored on disk (executable file), process is active Program becomes process when executable file loaded into memory Execution of program started via GUI mouse clicks, command line entry of its name, etc. One program can be several processes Consider multiple users executing the same program Process in Memory A process in memory is a program in execution. When a program is loaded into memory, it becomes a process. The process in memory typically consists of several key components: Text section (code) Data section (global variables) Heap (dynamically allocated memory) Stack (temporary data storage, function parameters, return addresses) These components are allocated specific areas in the memory, allowing the operating system to manage and execute the process efficiently. Process States As a process executes, it changes state. New Running The new state represents when the process is being In the running state, instructions are being executed created. by the processor. Waiting Ready The waiting state occurs when the process is waiting In the ready state, the process is waiting to be for some event to occur. assigned to a processor. Terminated The terminated state indicates that the process has finished execution. Diagram of Process State The diagram of process state illustrates the various states a process can be in during its lifecycle. Key states typically shown in such a diagram include: New Ready Running Waiting Terminated The arrows between these states depict the possible transitions a process can undergo based on system events and scheduling decisions. Process Control Block (PCB) Definition and Purpose The Process Control Block (PCB), also called task control block, is a data structure that contains information associated with each process. It serves as a repository for all the data needed to manage and control a process effectively. Key Components Process state – running, waiting, etc. Program counter – location of instruction to next execute CPU registers – contents of all process-centric registers CPU scheduling information- priorities, scheduling queue pointers Memory-management information – memory allocated to the process Accounting information – CPU used, clock time elapsed since start, time limits I/O status information – I/O devices allocated to process, list of open files CPU Switch From Process to Process The CPU switches from one process to another in a sequence of steps. This process, known as a context switch, involves saving the state of the current process, selecting the next process to run, restoring the state of the new process, and finally executing the new process. Process Representation in Linux Represented by the C structure task_struct Process Scheduling Maximizing CPU Usage Maximize CPU use, quickly switch processes onto CPU for time sharing Process Scheduler Process scheduler selects among available processes for next execution on CPU Scheduling Queues Maintains scheduling queues of processes Job Queue Job queue – set of all processes in the system Ready Queue Ready queue – set of all processes residing in main memory, ready and waiting to execute Device Queues Device queues – set of processes waiting for an I/O device Queue Migration Processes migrate among the various queues Ready Queue And Various I/O Device Queues I/O Device Queues Various I/O device queues exist in a computer system, each associated with a specific I/O device. These queues hold processes that are waiting for input/output operations to complete, ensuring efficient management of system resources. Representation of Process Scheduling Queueing diagram represents queues, resources, flowsA queueing diagram effectively represents: This diagram provides a clear and comprehensive view of how processes move through the system, making it an invaluable tool for visualizing and analyzing process scheduling mechanisms. Schedulers in Operating Systems Understanding the different types of schedulers and their roles in process management Types of Schedulers Short-term scheduler (CPU scheduler) Selects which process should be executed next and allocates CPU Sometimes the only scheduler in a system Invoked frequently (milliseconds) - must be fast Long-term scheduler (job scheduler) Selects which processes should be brought into the ready queue Invoked infrequently (seconds, minutes) - may be slow Controls the degree of multiprogramming Process Types 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 scheduler strives for good process mix by Mr.Yudi K. Budi Medium Term Scheduling Introduction of Swapping Process Medium-term Swapping involves removing a process from Scheduler memory, storing it on disk, and then bringing it back in A medium-term scheduler can be added when from disk to continue execution. there's a need to decrease the degree of multiple programming in the system. Operations on Processes Process Creation Process Additional The system must provide mechanisms Termination Operations for process creation, allowing new Mechanisms for process termination The system must provide mechanisms processes to be initiated and managed are essential, enabling the system to for other operations on processes, as effectively. end processes when necessary or detailed in subsequent sections, to requested. ensure comprehensive process management. Process Creation 1 Parent Process 2 Children Processes 3 Grandchildren Processes Parent processes create children processes, which, in turn create other processes, forming a tree of processes. Generally, processes are identified and managed via a process identifier (pid). Resource Sharing Options: Parent and children share all resources Children share subset of parent's resources Parent and child share no resources Execution Options: Parent and children execute concurrently Parent waits until children terminate A Tree of Processes in Linux In the Linux operating system, processes are organized in a hierarchical tree structure. This tree-like arrangement reflects the parent-child relationships between processes, showcasing how new processes are created and how they relate to one another within the system. Process Creation (Cont.) Address space: Child process is created with its own address space Child process is initially a duplicate of the parent process Child process can have a new program loaded into it UNIX examples demonstrate process creation mechanisms fork() system call is used to create a new process exec() system call is typically used after a fork() to replace the process' memory space with a new program C Program Forking Separate Process Creating a Separate Process via Windows API Windows API Process Creation The Windows API provides powerful tools for creating separate processes in Windows operating systems. This functionality allows developers to spawn new processes programmatically, enabling multi-process applications and system utilities. Process Termination Process executes last statement and then asks the operating system to delete it using the exit() system call. Returns status data from child to parent (via wait()) Process resources are deallocated by operating system Parent may terminate the execution of children processes using the abort() system call. Some reasons for doing so: Child has exceeded allocated resources Task assigned to child is no longer required The parent is exiting and the operating systems does not allow a child to continue if its parent terminates Interprocess Communication Types of Reasons for Interprocess Processes Cooperation Communication Processes within a system may be Information sharing (IPC) independent or cooperating. Computation speedup Cooperating processes need Cooperating processes can affect or interprocess communication Modularity be affected by other processes, (IPC). Two models of IPC are: Convenience including sharing data. Shared memory Message passing Communications Models There are two main communications models for interprocess communication: (a) Message passing (b) Shared memory These models provide different mechanisms for processes to exchange information and coordinate their activities within a computer system. Cooperating Processes Types of 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 Interprocess Communication – Shared Memory An area of memory shared among the processes that wish to communicate The communication is under the control of the users processes not the operating system Major issues is to provide mechanism that will allow the user processes to synchronize their actions when they access shared memory Synchronization is discussed in great details in Chapter 5 Interprocess Communication – Message Passing 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) receive(message) The message size is either fixed or variable Synchronization in Message Passing Blocking (Synchronous) Non-blocking (Asynchronous) Blocking send: sender blocked Non-blocking send: sender until message received continues after sending Blocking receive: receiver blocked Non-blocking receive: receiver until message available gets valid or null message Rendezvous: both send and Various combinations possible receive are blocking Pipes: A Conduit for Process Communication Conduit Pipes act as a conduit allowing two processes to communicate. Key Issues Directionality, duplex mode, process relationships, and network compatibility are important considerations. Ordinary Pipes Cannot be accessed from outside the creating process, typically used for parent-child communication. Named Pipes Can be accessed without a parent-child relationship, allowing more flexible communication. Ordinary and Named Pipes Ordinary Pipes 1 Unidirectional, producer-consumer style communication. Require parent-child relationship. Windows calls these anonymous pipes. Named Pipes 2 More powerful, bidirectional communication. No parent-child relationship necessary. Several processes can use the named pipe for communication. Availability 3 Provided on both UNIX and Windows systems, offering flexible inter-process communication options. Principles of Deadlock To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks. To present a number of different methods for preventing or avoiding deadlocks in a computer system The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set Example: System has 2 disk drives P1 and P2 each hold one disk drive and each needs another one Deadlock example Graph With A Cycle But No Deadlock Methods for Handling Deadlocks Ensure that the system will never enter a deadlock state. Allow the system to enter a deadlock state and then recover. Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX Deadlock Prevention Restrain the ways request can be made Mutual Exclusion – not required for sharable resources; must hold for non- sharable resources Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources SCHEDULING In multiprogramming environment, more than one program (process or job) is in execution. Multiprogramming, operating system that allows a single user to work on two or more applications that reside in memory at the same time. Multiprogramming is an attempt to increase CPU utilization by always having something for the CPU to execute. The main issue is to decide which program and how long should it be allowed to use resources The scheduling algorithms should: Be fair – If all process have the same priorities, no process should be starved or postponed indefinitely. Predictable – A given job should cost the same amount of time, regardless of the load. Long Term Schedulers The long term scheduler controls the degree of multiprogramming. If the degree of multiprogramming is stable, then the average rate of process creation must be equal to the average departure rate of process leaving the system. The Short Term Scheduler The short term scheduler must select from among the processes that are ready to execute and allocates the CPU to one of them. The short term scheduler selects from among the processes that are ready to execute and to allocates the CPU to one of them Differences Between Pre-emptive and Non- Pre-emptive Scheduling “Pre-emptive scheduling” the CPU is allocated to the processes for the limited time. “Non-pre-emptive scheduling”, the CPU is allocated to the process until it terminates or switches to waiting state. Operating System Scheduling Algorithms There are FOUR (4) popular process scheduling algorithms : First-Come, First-Served (FCFS) Scheduling Shortest-Job-Next (SJN) Scheduling Priority Scheduling Round Robin(RR) Scheduling

Use Quizgecko on...
Browser
Browser