0% found this document useful (0 votes)
3 views22 pages

Lecture_3

The document outlines key concepts in operating systems, focusing on process management, including the states of processes and the role of schedulers. It discusses the differences between long-term, short-term, and medium-term schedulers, as well as the importance of balancing I/O-bound and CPU-bound processes. Additionally, it covers interprocess communication mechanisms and synchronization methods essential for process cooperation.

Uploaded by

Ahmed Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views22 pages

Lecture_3

The document outlines key concepts in operating systems, focusing on process management, including the states of processes and the role of schedulers. It discusses the differences between long-term, short-term, and medium-term schedulers, as well as the importance of balancing I/O-bound and CPU-bound processes. Additionally, it covers interprocess communication mechanisms and synchronization methods essential for process cooperation.

Uploaded by

Ahmed Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Assiut University

Course Title: Operating Systems


Course Code: CS321

Prof. Khaled F. Hussain


Reference
• Silberschatz, Abraham, Peter B. Galvin, and Greg
Gagne. Operating system concepts. John Wiley & Sons.
Process Management
• A process can be thought of as a program in execution. A process will need certain resources—
such as CPU time, memory, files, and I/O devices —to accomplish its task.
• Systems consist of a collection of processes
• A process contained only a single thread of control as it ran, most modern operating systems now
support processes that have multiple threads.
Process in memory
Process State
• New. The process is being created.
• Running. Instructions are being executed.
• Waiting. The process is waiting for some event to occur (such as an I/O completion or reception of a
signal).
• Ready. The process is waiting to be assigned to a processor.
• Terminated. The process has finished execution.
Diagram of process state
Process
control block
(PCB)
Diagram
showing CPU
switch from
process to
process
Threads
• For example, when a process is running a word-processor program, a single thread of instructions
is being executed. This single thread of control allows the process to perform only one task at a
time.
• The user cannot simultaneously type in characters and run the spell checker within the same
process, for example. Most modern operating systems
• have extended the process concept to allow a process to have multiple threads of execution and
thus to perform more than one task at a time.
Single-threaded and multithreaded processes
The ready
queue and
various I/O
device
queues
Queueing-
diagram
representation
of process
scheduling
Schedulers
• The long-term scheduler, or job scheduler, selects processes from this pool and loads them into
memory for execution.
• The short-term scheduler, or CPU scheduler, selects from among the processes that are ready to
execute and allocates the CPU to one of them.
• The primary distinction between these two schedulers lies in frequency of execution. The short-
term scheduler must select a new process for the CPU frequently. A process may execute for only a
few milliseconds before waiting for an I/O request. Often, the short-term scheduler executes at least
once every 100 milliseconds.
• The long-term scheduler executes much less frequently; minutes may separate the creation of one
new process and the next. The long-term scheduler controls the degree of multiprogramming (the
number of processes in memory).
Schedulers (Cont.)
• It is important that the long-term scheduler make a careful selection. In general, most processes can
be described as either I/O bound or CPU bound.
• An I/O-bound process is one that spends more of its time doing I/O than it spends doing
computations.
• A CPU-bound process, in contrast, generates I/O requests infrequently, using more of its time
doing computations.
• It is important that the long-term scheduler select a good process mix of I/O-bound and CPU-bound
processes.
• If all processes are I/O bound, the ready queue will almost always be empty, and the short-term
scheduler will have little to do.
• If all processes are CPU bound, the I/O waiting queue will almost always be empty, devices will go
unused, and again the system will be unbalanced.
Medium-term scheduler
• Some operating systems, such as time-sharing systems, may introduce an additional, intermediate
level of scheduling: medium-term scheduler.
• The key idea behind a medium-term scheduler is that sometimes it can be advantageous to remove
a process from memory (and from active contention for the CPU) and thus reduce the degree of
multiprogramming. Later, the process can be reintroduced into memory, and its execution can be
continued where it left off. This scheme is called swapping.
• The process is swapped out, and is later swapped in, by the medium-term scheduler. Swapping
may be necessary to improve the process mix.
Addition of medium-term scheduling to the
queueing diagram
Operations on Processes
• Process Creation
• Process Termination
• ….
Creating a
separate
process using
the UNIX fork()
system call
Creating a
separate
process
using the
Windows API
Interprocess Communication
• There are several reasons for providing an environment that allows process cooperation:
• Information sharing. Since several users may be interested in the same piece of
information (for instance, a shared file), we must provide an environment to allow
concurrent access to such information.
• Computation speedup. If we want a particular task to run faster, we must break it
into subtasks, each of which will be executing in parallel with the others. Notice that
such a speedup can be achieved only if the computer has multiple processing cores.
• Modularity. We may want to construct the system in a modular fashion, dividing the
system functions into separate processes or threads.
• Convenience. Even an individual user may work on many tasks at the same time. For
instance, a user may be editing, listening to music, and compiling in parallel.
Interprocess communication (IPC)
• Cooperating processes require an interprocess communication (IPC) mechanism that will allow
them to exchange data and information. There are two fundamental models of interprocess
communication: a) message passing and b) shared memory.
Synchronization
• Communication between processes takes place through calls to send() and receive() primitives.
• Message passing may be either blocking or nonblocking— also known as synchronous and
asynchronous.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy