UCI ICS 143 - Principles of Operating Systems

Unformatted text preview:

ICS 143 - Principles of Operating SystemsOutlineProcess ConceptProcess StateProcess StatesProcess Control BlockProcess Scheduling QueuesProcess QueuesSlide 9SchedulersMedium Term (Time-sharing) SchedulerProcess ProfilesContext SwitchProcess CreationUNIX Process HierarchySlide 16UNIX Process CreationProcess TerminationCooperating ProcessesThreadsSlide 21Threads(Cont.)Threads (cont.)Slide 24Thread Support in Solaris 2Threads in Solaris 2Slide 27Interprocess Communication (IPC)Producer-Consumer using IPCCooperating Processes via Message PassingImplementation QuestionsDirect CommunicationIndirect CommunicationIndirect Communication using mailboxesMailboxes (cont.)Message BufferingMessage Problems - Exception ConditionsSlide 38Producer-Consumer ProblemSlide 40Bounded-buffer - Shared Memory SolutionBounded Buffer - Shared Memory SolutionSlide 43ICS 143 - Principles of Operating SystemsLectures 3 and 4 - Processes and ThreadsProf. Nalini [email protected]Process ConceptProcess SchedulingOperations on ProcessesCooperating ProcessesThreadsInterprocess CommunicationProcess 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process execution proceeds in a sequential fashionA process containsprogram counter, stack and data sectionProcess StateA process changes state as it executes.newnewadmittedinterruptI/O oreventcompletionSchedulerdispatchI/O orevent waitexitreadyrunningterminatedwaitingProcess 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.Process Control BlockContains information associated with each process•Process State - e.g. new, ready, running etc.•Program Counter - address of next instruction to be executed•CPU registers - general purpose registers, stack pointer etc. •CPU scheduling information - process priority, pointer•Memory Management information - base/limit information•Accounting information - time limits, process number•I/O Status information - list of I/O devices allocatedProcess 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.Process QueuesDeviceQueueReadyQueueProcess Scheduling QueuesSchedulers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 throughputMedium Term (Time-sharing) SchedulerProcess 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 processesContext 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•can become a bottleneckTime for context switch is dependent on hardware support ( 1- 1000 microseconds).Process 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.UNIX Process HierarchyProcess 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.UNIX Process CreationFork system call creates new processesexecve system call is used after a fork to replace the processes memory space with a new program.Process TerminationProcess executes last statement and asks the operating system to delete it (exit).•Output data from child to parent (via wait).•Process’ resources are deallocated by operating system.Parent may terminate execution of child processes.•Child has exceeded allocated resources.•Task assigned to child is no longer required.•Parent is exiting–OS does not allow child to continue if parent terminates–Cascading terminationCooperating ProcessesConcurrent Processes can be •Independent processes –cannot affect or be affected by the execution of another process.•Cooperating processes –can affect or be affected by the execution of another process.Advantages of process cooperation:–Information sharing–Computation speedup–Modularity–Convenience(e.g. editing, printing, compiling)Concurrent execution requires–process communication and process synchronizationThreadsProcesses do not share resources well •high context switching overheadA thread (or lightweight process) •basic unit of CPU utilization; it consists of:–program counter, register set and stack spaceA thread shares the following with peer threads:–code section, data section and OS resources (open files, signals)Collectively called a task.Heavyweight process is a task with one thread.ThreadsProgram counterThreads(Cont.)In a multiple threaded task, while one server thread is blocked and waiting, a second thread in the same task can run.Cooperation of multiple threads in the same job confers higher throughput and improved


View Full Document

UCI ICS 143 - Principles of Operating Systems

Download Principles of Operating Systems
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Principles of Operating Systems and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Principles of Operating Systems 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?