SlideShare a Scribd company logo
Processes
3.2
Chapter 3: Processes
ïź Process Concept
ïź Process Scheduling
ïź Operations on Processes
ïź Interprocess Communication
ïź Examples of IPC Systems
ïź Communication in Client-Server Systems
3.3
Objectives
ïź To introduce the idea of a process -- a
program in execution, which forms the
basis of all calculation
ïź To describe the various features of
processes, including scheduling,
creation and termination, and
communication
ïź To describe communication in client-
server systems
3.4
Process
ïź Process ---- Program in execution
ïź process-- Instance of a running program
ïź Program counter -- Address of the next
instruction to be executed
ïź Data section --- Global variable
ïź Stack -- Temporary data, return the address
ïź Process is a active entity -- Program is a
passive entity
ïź
3.5
Process
ïź An execution of program is a process. It is an
active entity . It contain program code as well as
current information of executing program.
ïź It has a program counter which store address of
the next instruction ,stack,CPU register, data
section.
3.6
Process Concept
ïź An operating system executes a variety of
programs:
ïŹ Batch system – jobs
ïŹ Time-shared systems – user programs or tasks
ïź Process – a program in execution; process
execution must progress in sequential fashion
ïź A process includes:
ïŹ program counter
ïŹ stack
ïŹ data section
3.7
Diagram of Process State
3.8
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 processor
ïŹ terminated: The process has finished
execution
3.9
Process in Memory
3.10
Process in Memory
ïź Text section-- Consist of compiled program
code.
ïź Data Section-- allocated and initialized to
executing e.g: Global variable
ïź Heap-- memory dynamically allocated during
process runtime
ïź Stack.-- containing temporary data.
3.11
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
3.12
Process Control Block (PCB)
ïź Data structured maintained by OS for every
process
ïź PCB identified by an integer process ID (PID).
ïź PCB keeps all the information needed to keep
track of the process.
3.13
Process Control Block (PCB)
3.14
CPU Switch From Process to Process
3.15
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
ïź Processes migrate among the various
queues
3.16
Types of scheduling
ïź Preemptive scheduling--- CPU can be taken
away from running process at any time weather
the process has completed its execution or not.
1. If the process switches Running to Ready state.
2. If the process switches from waiting to ready
state.
 Non- Preemptive scheduling-- In this state,
CPU can’t be taken away from the process till
the process completes it’s execution or
terminates.
1. If the process switches from Running to waiting
3.17
Ready Queue And Various I/O Device Queues
3.18
Representation of Process Scheduling
3.19
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
ïź Medium Term Scheduling
Time sharing system
3.20
Addition of Medium Term Scheduling
3.21
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
3.22
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 via a context
switch
ïź Context of a process represented in the PCB
ïź In the Context-switch the process is stored in PCB to save the new process
ïź So that old process can be resumed from the same part it was left
ïź To make context switch time to be less , registers which are the fastest
access memory are used.
3.23
Process Creation
ïź Parent process create children processes, which, in turn create other
processes, forming a tree of processes
ïź Generally, process identified and managed via a process identifier (pid)
ïź Resource sharing
ïŹ Parent and children share all resources
ïŹ Children share subset of parent’s resources
ïź Execution
ïŹ Parent and children execute concurrently
ïŹ Parent waits until children terminate
3.24
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
3.25
Process Creation
3.26
C Program Forking Separate Process
int main()
{
pid_t pid;
/* fork another process */
pid = fork();
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
exit(-1);
}
else if (pid == 0) { /* child process */
execlp("/bin/ls", "ls", NULL);
}
else { /* parent process */
/* parent will wait for the child to complete */
wait (NULL);
printf ("Child Complete");
exit(0);
}
}
3.27
A tree of processes on a typical Solaris
3.28
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 children processes (abort)
ïŹ Child has exceeded allocated resources
ïŹ Task assigned to child is no longer required
 If parent is exiting
 Some operating system do not allow child to continue if its
parent terminates
– All children terminated - cascading termination
3.29
Inter process Communication
ïź It is a mechanism that allow the processes to communicate each
other and synchronize .
ïź Processes within a system may be independent or cooperating
ïź Cooperating process can affect by other executing program o
ïź Independent process can not be affected by other processes,
including sharing data
ïź It is a mechanism allow process to communicate with each other
and synchronize their action.
ïź Reasons for cooperating processes:
ïŹ Information sharing
ïŹ Computation speedup
ïŹ Resource sharing
ïŹ Synchronization
ïŹ Modularity
ïŹ Convenience
3.30
Inter process Communication
ïź Cooperating processes need inter process communication (IPC)
ïź Two models of IPC
ïŹ Shared memory- Process save the record in shared memory
ïŹ Message passing-- process communicate with each other with out
using the shared memory.
P1-p2: ---1st establish the communication link
--- 2nd start exchange message using basic primitives
‱ Send
‱ Receive
ïź Message passing will be direct or indirect communication
ïź Symmetric or asymmetric
ïź Automatic
ïź
3.31
Communications Models
3.32
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
modularity is the degree to which a system's components may be
separated and recombined, often with the benefit of flexibility and variety in
use
3.33
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
3.34
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
3.35
Bounded-Buffer – Producer
while (true) {
/* Produce an item */
int count=0;
void producer(void)
int itemp;
while (true){
produce-item(itemp);
while while (count==n);// buffer full
buffer[in]=itemp;
in=(in+1)modn;
Count=count+1;
}
}
3.36
Bounded Buffer – Consumer
int itemc;
while (true) {
while (count== 0)// Buffer empety
; // do nothing -- nothing to consume
// remove an item from the buffer
itemc = buffer[out]modn;
count=count-1;
process item(itemc);
return item;
}
3.37
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) – 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)
ïŹ logical (e.g., logical properties)
3.38
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?
3.39
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
3.40
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
3.41
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
3.42
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.
3.43
Synchronization
ïź Message passing may be either blocking or non-blocking
ïź Blocking is considered synchronous
ïŹ Blocking send has the sender block until the message is
received
ïŹ Blocking receive has the receiver block until a message is
available
ïź Non-blocking is considered asynchronous
ïŹ Non-blocking send has the sender send the message and
continue
ïŹ Non-blocking receive has the receiver receive a valid message
or null
3.44
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
3.45
Examples of IPC Systems - POSIX
ïź POSIX Shared Memory
ïŹ Process first creates shared memory segment
segment id = shmget(IPC PRIVATE, size, S IRUSR | S
IWUSR);
ïŹ Process wanting access to that shared memory must attach to it
shared memory = (char *) shmat(id, NULL, 0);
ïŹ Now the process could write to the shared memory
sprintf(shared memory, "Writing to shared memory");
ïŹ When done a process can detach the shared memory from its address
space
shmdt(shared memory);
3.46
Examples of IPC Systems - Mach
ïź Mach communication is message based
ïŹ Even system calls are messages
ïŹ Each task gets two mailboxes at creation- Kernel and Notify
ïŹ Only three system calls needed for message transfer
msg_send(), msg_receive(), msg_rpc()
ïŹ Mailboxes needed for commuication, created via
port_allocate()
3.47
Examples of IPC Systems – Windows XP
ïź Message-passing centric via local procedure call (LPC) facility
ïŹ Only works between processes on the same system
ïŹ Uses ports (like mailboxes) to establish and maintain communication
channels
ïŹ Communication works as follows:
 The client opens a handle to the subsystem’s connection port object
 The client sends a connection request
 The server creates two private communication ports and returns the
handle to one of them to the client
 The client and server use the corresponding port handle to send
messages or callbacks and to listen for replies
3.48
Local Procedure Calls in Windows XP
3.49
Communications in Client-Server Systems
ïź Sockets
ïź Remote Procedure Calls
ïź Remote Method Invocation (Java)
3.50
Sockets
ïź A socket is defined as an endpoint for communication
ïź Concatenation of IP address and port
ïź The socket 161.25.19.8:1625 refers to port 1625 on host
161.25.19.8
ïź Communication consists between a pair of sockets
3.51
Socket Communication
3.52
Remote Procedure Calls
ïź Remote procedure call (RPC) abstracts procedure calls between processes
on networked systems
ïź Stubs – client-side proxy for the actual procedure on the server
ïź The client-side stub locates the server and marshalls the parameters
ïź The server-side stub receives this message, unpacks the marshalled
parameters, and peforms the procedure on the server
3.53
Execution of RPC
3.54
Remote Method Invocation
ïź Remote Method Invocation (RMI) is a Java mechanism similar to RPCs
ïź RMI allows a Java program on one machine to invoke a method on a
remote object
3.55
Marshalling Parameters
Ad

More Related Content

Similar to OSLec 4& 5(Processesinoperatingsystem).ppt (20)

Ch03- PROCESSES.ppt
Ch03- PROCESSES.pptCh03- PROCESSES.ppt
Ch03- PROCESSES.ppt
MeghaSharma474761
 
Process
ProcessProcess
Process
Sachin MK
 
OSCh4
OSCh4OSCh4
OSCh4
Joe Christensen
 
OS_Ch4
OS_Ch4OS_Ch4
OS_Ch4
Supriya Shrivastava
 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OS
C.U
 
CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2
Kathirvel Ayyaswamy
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
Kathirvel Ayyaswamy
 
UNIT I Process management main concept.ppt
UNIT I Process management main concept.pptUNIT I Process management main concept.ppt
UNIT I Process management main concept.ppt
vaibavmugesh
 
CH03.pdf
CH03.pdfCH03.pdf
CH03.pdf
ImranKhan880955
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
DiptoRoy21
 
Unit 2 chapter notes for the student1-1.ppt
Unit 2 chapter  notes for the student1-1.pptUnit 2 chapter  notes for the student1-1.ppt
Unit 2 chapter notes for the student1-1.ppt
Rajasekhar364622
 
unit-2.pdf
unit-2.pdfunit-2.pdf
unit-2.pdf
071ROHETHSIT
 
ch3 (1).ppt
ch3 (1).pptch3 (1).ppt
ch3 (1).ppt
AniketChavan493584
 
Operating System
Operating SystemOperating System
Operating System
Indhu Periys
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
csomab4u
 
Lecture_Process.ppt
Lecture_Process.pptLecture_Process.ppt
Lecture_Process.ppt
RahulKumarYadav87
 
Processes
ProcessesProcesses
Processes
K Gowsic Gowsic
 
cs8493 - operating systems unit 2
cs8493 - operating systems unit 2cs8493 - operating systems unit 2
cs8493 - operating systems unit 2
SIMONTHOMAS S
 
process management.ppt
process management.pptprocess management.ppt
process management.ppt
ShubhamGoel184057
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
FernandezPineda2
 
Process
ProcessProcess
Process
Sachin MK
 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OS
C.U
 
CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2
Kathirvel Ayyaswamy
 
UNIT I Process management main concept.ppt
UNIT I Process management main concept.pptUNIT I Process management main concept.ppt
UNIT I Process management main concept.ppt
vaibavmugesh
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
DiptoRoy21
 
Unit 2 chapter notes for the student1-1.ppt
Unit 2 chapter  notes for the student1-1.pptUnit 2 chapter  notes for the student1-1.ppt
Unit 2 chapter notes for the student1-1.ppt
Rajasekhar364622
 
Operating System
Operating SystemOperating System
Operating System
Indhu Periys
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
csomab4u
 
cs8493 - operating systems unit 2
cs8493 - operating systems unit 2cs8493 - operating systems unit 2
cs8493 - operating systems unit 2
SIMONTHOMAS S
 
process management.ppt
process management.pptprocess management.ppt
process management.ppt
ShubhamGoel184057
 

More from ssusere16bd9 (20)

OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
ssusere16bd9
 
Agents and environment.pptx
Agents and environment.pptxAgents and environment.pptx
Agents and environment.pptx
ssusere16bd9
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
ssusere16bd9
 
Data Communication-1.ppt
Data Communication-1.pptData Communication-1.ppt
Data Communication-1.ppt
ssusere16bd9
 
COMPUTER ARCHITECTURE-2.pptx
COMPUTER ARCHITECTURE-2.pptxCOMPUTER ARCHITECTURE-2.pptx
COMPUTER ARCHITECTURE-2.pptx
ssusere16bd9
 
jyatesproject4-111025223823-phpapp02.pptx
jyatesproject4-111025223823-phpapp02.pptxjyatesproject4-111025223823-phpapp02.pptx
jyatesproject4-111025223823-phpapp02.pptx
ssusere16bd9
 
What is SRS & REP.pptx
What is SRS & REP.pptxWhat is SRS & REP.pptx
What is SRS & REP.pptx
ssusere16bd9
 
semantic web.pptx
semantic web.pptxsemantic web.pptx
semantic web.pptx
ssusere16bd9
 
business communication.pptx
business communication.pptxbusiness communication.pptx
business communication.pptx
ssusere16bd9
 
xml and xhtml.pptx
xml and xhtml.pptxxml and xhtml.pptx
xml and xhtml.pptx
ssusere16bd9
 
cloudcomputing5-141224231751-conversion-gate02-1.pptx
cloudcomputing5-141224231751-conversion-gate02-1.pptxcloudcomputing5-141224231751-conversion-gate02-1.pptx
cloudcomputing5-141224231751-conversion-gate02-1.pptx
ssusere16bd9
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
ssusere16bd9
 
SE PRESENTATION (1).pptx
SE PRESENTATION (1).pptxSE PRESENTATION (1).pptx
SE PRESENTATION (1).pptx
ssusere16bd9
 
CBSE.pptx
CBSE.pptxCBSE.pptx
CBSE.pptx
ssusere16bd9
 
What is SRS & REP.pptx
What is SRS & REP.pptxWhat is SRS & REP.pptx
What is SRS & REP.pptx
ssusere16bd9
 
How social Norms is Understood as Deviant Behavior-rauf.pptx
How social Norms is Understood as Deviant Behavior-rauf.pptxHow social Norms is Understood as Deviant Behavior-rauf.pptx
How social Norms is Understood as Deviant Behavior-rauf.pptx
ssusere16bd9
 
SE Lecture 1.ppt
SE Lecture 1.pptSE Lecture 1.ppt
SE Lecture 1.ppt
ssusere16bd9
 
SE Lecture 2.ppt
SE Lecture 2.pptSE Lecture 2.ppt
SE Lecture 2.ppt
ssusere16bd9
 
SE Lecture 1.ppt
SE Lecture 1.pptSE Lecture 1.ppt
SE Lecture 1.ppt
ssusere16bd9
 
SE Lecture 3.ppt
SE Lecture 3.pptSE Lecture 3.ppt
SE Lecture 3.ppt
ssusere16bd9
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
ssusere16bd9
 
Agents and environment.pptx
Agents and environment.pptxAgents and environment.pptx
Agents and environment.pptx
ssusere16bd9
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
ssusere16bd9
 
Data Communication-1.ppt
Data Communication-1.pptData Communication-1.ppt
Data Communication-1.ppt
ssusere16bd9
 
COMPUTER ARCHITECTURE-2.pptx
COMPUTER ARCHITECTURE-2.pptxCOMPUTER ARCHITECTURE-2.pptx
COMPUTER ARCHITECTURE-2.pptx
ssusere16bd9
 
jyatesproject4-111025223823-phpapp02.pptx
jyatesproject4-111025223823-phpapp02.pptxjyatesproject4-111025223823-phpapp02.pptx
jyatesproject4-111025223823-phpapp02.pptx
ssusere16bd9
 
What is SRS & REP.pptx
What is SRS & REP.pptxWhat is SRS & REP.pptx
What is SRS & REP.pptx
ssusere16bd9
 
semantic web.pptx
semantic web.pptxsemantic web.pptx
semantic web.pptx
ssusere16bd9
 
business communication.pptx
business communication.pptxbusiness communication.pptx
business communication.pptx
ssusere16bd9
 
xml and xhtml.pptx
xml and xhtml.pptxxml and xhtml.pptx
xml and xhtml.pptx
ssusere16bd9
 
cloudcomputing5-141224231751-conversion-gate02-1.pptx
cloudcomputing5-141224231751-conversion-gate02-1.pptxcloudcomputing5-141224231751-conversion-gate02-1.pptx
cloudcomputing5-141224231751-conversion-gate02-1.pptx
ssusere16bd9
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
ssusere16bd9
 
SE PRESENTATION (1).pptx
SE PRESENTATION (1).pptxSE PRESENTATION (1).pptx
SE PRESENTATION (1).pptx
ssusere16bd9
 
What is SRS & REP.pptx
What is SRS & REP.pptxWhat is SRS & REP.pptx
What is SRS & REP.pptx
ssusere16bd9
 
How social Norms is Understood as Deviant Behavior-rauf.pptx
How social Norms is Understood as Deviant Behavior-rauf.pptxHow social Norms is Understood as Deviant Behavior-rauf.pptx
How social Norms is Understood as Deviant Behavior-rauf.pptx
ssusere16bd9
 
SE Lecture 1.ppt
SE Lecture 1.pptSE Lecture 1.ppt
SE Lecture 1.ppt
ssusere16bd9
 
SE Lecture 2.ppt
SE Lecture 2.pptSE Lecture 2.ppt
SE Lecture 2.ppt
ssusere16bd9
 
SE Lecture 1.ppt
SE Lecture 1.pptSE Lecture 1.ppt
SE Lecture 1.ppt
ssusere16bd9
 
SE Lecture 3.ppt
SE Lecture 3.pptSE Lecture 3.ppt
SE Lecture 3.ppt
ssusere16bd9
 
Ad

Recently uploaded (20)

AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Applying AI in Marketo: Practical Strategies and Implementation
Applying AI in Marketo: Practical Strategies and ImplementationApplying AI in Marketo: Practical Strategies and Implementation
Applying AI in Marketo: Practical Strategies and Implementation
BradBedford3
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
S3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athenaS3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athena
aianand98
 
User interface and User experience Modernization.pptx
User interface and User experience  Modernization.pptxUser interface and User experience  Modernization.pptx
User interface and User experience Modernization.pptx
MustafaAlshekly1
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
iTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation KeyiTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation Key
raheemk1122g
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Applying AI in Marketo: Practical Strategies and Implementation
Applying AI in Marketo: Practical Strategies and ImplementationApplying AI in Marketo: Practical Strategies and Implementation
Applying AI in Marketo: Practical Strategies and Implementation
BradBedford3
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
S3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athenaS3 + AWS Athena how to integrate s3 aws plus athena
S3 + AWS Athena how to integrate s3 aws plus athena
aianand98
 
User interface and User experience Modernization.pptx
User interface and User experience  Modernization.pptxUser interface and User experience  Modernization.pptx
User interface and User experience Modernization.pptx
MustafaAlshekly1
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
iTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation KeyiTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation Key
raheemk1122g
 
Ad

OSLec 4& 5(Processesinoperatingsystem).ppt

  • 2. 3.2 Chapter 3: Processes ïź Process Concept ïź Process Scheduling ïź Operations on Processes ïź Interprocess Communication ïź Examples of IPC Systems ïź Communication in Client-Server Systems
  • 3. 3.3 Objectives ïź To introduce the idea of a process -- a program in execution, which forms the basis of all calculation ïź To describe the various features of processes, including scheduling, creation and termination, and communication ïź To describe communication in client- server systems
  • 4. 3.4 Process ïź Process ---- Program in execution ïź process-- Instance of a running program ïź Program counter -- Address of the next instruction to be executed ïź Data section --- Global variable ïź Stack -- Temporary data, return the address ïź Process is a active entity -- Program is a passive entity ïź
  • 5. 3.5 Process ïź An execution of program is a process. It is an active entity . It contain program code as well as current information of executing program. ïź It has a program counter which store address of the next instruction ,stack,CPU register, data section.
  • 6. 3.6 Process Concept ïź An operating system executes a variety of programs: ïŹ Batch system – jobs ïŹ Time-shared systems – user programs or tasks ïź Process – a program in execution; process execution must progress in sequential fashion ïź A process includes: ïŹ program counter ïŹ stack ïŹ data section
  • 8. 3.8 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 processor ïŹ terminated: The process has finished execution
  • 10. 3.10 Process in Memory ïź Text section-- Consist of compiled program code. ïź Data Section-- allocated and initialized to executing e.g: Global variable ïź Heap-- memory dynamically allocated during process runtime ïź Stack.-- containing temporary data.
  • 11. 3.11 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
  • 12. 3.12 Process Control Block (PCB) ïź Data structured maintained by OS for every process ïź PCB identified by an integer process ID (PID). ïź PCB keeps all the information needed to keep track of the process.
  • 14. 3.14 CPU Switch From Process to Process
  • 15. 3.15 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 ïź Processes migrate among the various queues
  • 16. 3.16 Types of scheduling ïź Preemptive scheduling--- CPU can be taken away from running process at any time weather the process has completed its execution or not. 1. If the process switches Running to Ready state. 2. If the process switches from waiting to ready state.  Non- Preemptive scheduling-- In this state, CPU can’t be taken away from the process till the process completes it’s execution or terminates. 1. If the process switches from Running to waiting
  • 17. 3.17 Ready Queue And Various I/O Device Queues
  • 19. 3.19 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 ïź Medium Term Scheduling Time sharing system
  • 20. 3.20 Addition of Medium Term Scheduling
  • 21. 3.21 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
  • 22. 3.22 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 via a context switch ïź Context of a process represented in the PCB ïź In the Context-switch the process is stored in PCB to save the new process ïź So that old process can be resumed from the same part it was left ïź To make context switch time to be less , registers which are the fastest access memory are used.
  • 23. 3.23 Process Creation ïź Parent process create children processes, which, in turn create other processes, forming a tree of processes ïź Generally, process identified and managed via a process identifier (pid) ïź Resource sharing ïŹ Parent and children share all resources ïŹ Children share subset of parent’s resources ïź Execution ïŹ Parent and children execute concurrently ïŹ Parent waits until children terminate
  • 24. 3.24 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
  • 26. 3.26 C Program Forking Separate Process int main() { pid_t pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execlp("/bin/ls", "ls", NULL); } else { /* parent process */ /* parent will wait for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0); } }
  • 27. 3.27 A tree of processes on a typical Solaris
  • 28. 3.28 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 children processes (abort) ïŹ Child has exceeded allocated resources ïŹ Task assigned to child is no longer required  If parent is exiting  Some operating system do not allow child to continue if its parent terminates – All children terminated - cascading termination
  • 29. 3.29 Inter process Communication ïź It is a mechanism that allow the processes to communicate each other and synchronize . ïź Processes within a system may be independent or cooperating ïź Cooperating process can affect by other executing program o ïź Independent process can not be affected by other processes, including sharing data ïź It is a mechanism allow process to communicate with each other and synchronize their action. ïź Reasons for cooperating processes: ïŹ Information sharing ïŹ Computation speedup ïŹ Resource sharing ïŹ Synchronization ïŹ Modularity ïŹ Convenience
  • 30. 3.30 Inter process Communication ïź Cooperating processes need inter process communication (IPC) ïź Two models of IPC ïŹ Shared memory- Process save the record in shared memory ïŹ Message passing-- process communicate with each other with out using the shared memory. P1-p2: ---1st establish the communication link --- 2nd start exchange message using basic primitives ‱ Send ‱ Receive ïź Message passing will be direct or indirect communication ïź Symmetric or asymmetric ïź Automatic ïź
  • 32. 3.32 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 modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use
  • 33. 3.33 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
  • 34. 3.34 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
  • 35. 3.35 Bounded-Buffer – Producer while (true) { /* Produce an item */ int count=0; void producer(void) int itemp; while (true){ produce-item(itemp); while while (count==n);// buffer full buffer[in]=itemp; in=(in+1)modn; Count=count+1; } }
  • 36. 3.36 Bounded Buffer – Consumer int itemc; while (true) { while (count== 0)// Buffer empety ; // do nothing -- nothing to consume // remove an item from the buffer itemc = buffer[out]modn; count=count-1; process item(itemc); return item; }
  • 37. 3.37 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) – 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) ïŹ logical (e.g., logical properties)
  • 38. 3.38 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?
  • 39. 3.39 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
  • 40. 3.40 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
  • 41. 3.41 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
  • 42. 3.42 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.
  • 43. 3.43 Synchronization ïź Message passing may be either blocking or non-blocking ïź Blocking is considered synchronous ïŹ Blocking send has the sender block until the message is received ïŹ Blocking receive has the receiver block until a message is available ïź Non-blocking is considered asynchronous ïŹ Non-blocking send has the sender send the message and continue ïŹ Non-blocking receive has the receiver receive a valid message or null
  • 44. 3.44 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
  • 45. 3.45 Examples of IPC Systems - POSIX ïź POSIX Shared Memory ïŹ Process first creates shared memory segment segment id = shmget(IPC PRIVATE, size, S IRUSR | S IWUSR); ïŹ Process wanting access to that shared memory must attach to it shared memory = (char *) shmat(id, NULL, 0); ïŹ Now the process could write to the shared memory sprintf(shared memory, "Writing to shared memory"); ïŹ When done a process can detach the shared memory from its address space shmdt(shared memory);
  • 46. 3.46 Examples of IPC Systems - Mach ïź Mach communication is message based ïŹ Even system calls are messages ïŹ Each task gets two mailboxes at creation- Kernel and Notify ïŹ Only three system calls needed for message transfer msg_send(), msg_receive(), msg_rpc() ïŹ Mailboxes needed for commuication, created via port_allocate()
  • 47. 3.47 Examples of IPC Systems – Windows XP ïź Message-passing centric via local procedure call (LPC) facility ïŹ Only works between processes on the same system ïŹ Uses ports (like mailboxes) to establish and maintain communication channels ïŹ Communication works as follows:  The client opens a handle to the subsystem’s connection port object  The client sends a connection request  The server creates two private communication ports and returns the handle to one of them to the client  The client and server use the corresponding port handle to send messages or callbacks and to listen for replies
  • 48. 3.48 Local Procedure Calls in Windows XP
  • 49. 3.49 Communications in Client-Server Systems ïź Sockets ïź Remote Procedure Calls ïź Remote Method Invocation (Java)
  • 50. 3.50 Sockets ïź A socket is defined as an endpoint for communication ïź Concatenation of IP address and port ïź The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 ïź Communication consists between a pair of sockets
  • 52. 3.52 Remote Procedure Calls ïź Remote procedure call (RPC) abstracts procedure calls between processes on networked systems ïź Stubs – client-side proxy for the actual procedure on the server ïź The client-side stub locates the server and marshalls the parameters ïź The server-side stub receives this message, unpacks the marshalled parameters, and peforms the procedure on the server
  • 54. 3.54 Remote Method Invocation ïź Remote Method Invocation (RMI) is a Java mechanism similar to RPCs ïź RMI allows a Java program on one machine to invoke a method on a remote object
  çż»èŻ‘ïŒš