Lecture 5
Lecture 5
Process concept
►Queues
Preamble ►Schedulers
(Past lesson
brief)
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Examples of IPC Systems
Communication in Client-Server Systems
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 proce
memory space with a new program
Some operating systems do not allow child to exists if its parent has
terminated. If a process terminates, then all its children must also
be terminated.
cascading termination. All children, grandchildren, etc. are
terminated.
The termination is initiated by the operating system.
The parent process may wait for termination of a child process by
using the wait()system call. The call returns status information
and the pid of the terminated process
pid = wait(&status);
If no parent waiting (did not invoke wait()) process is a zombie
(a zombie process or defunct process is a process that has
completed execution but still has an entry in the process table)
If parent terminated without invoking wait , process is an orphan
Lahore Garrison University
1
Multiprocess Architecture – Chrome 7
Browser
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 users to access these types of
resources.
Computation speed up:
If we want a particular task to run faster, we must break it into
subtasks each of which will be running in parallel with the
others. Such a speedup can be obtained only if the computer
has multiple processing elements (such as CPU’s or I/O
channels).
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 have many tasks on which
to work at one time. For instance, a user may be
editing, printing, and compiling in parallel.
Producer
Producer Consumer
Consumer
Full Pool
Lahore Garrison University
2
3
Bounded-Buffer – Shared-Memory Solution
Shared data
#define BUFFER_SIZE 10
typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
item next_produced;
while (true) {
/* produce an item in next produced */
while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
item next_consumed;
while (true) {
while (in == out)
; /* do nothing */
next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
Operations
create a new mailbox (port)
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
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.
message next_produced;
while (true) {
/* produce an item in next produced */
send(next_produced);
}
message next_consumed;
while (true) {
receive(next_consumed);
Sockets
Remote Procedure Calls
Pipes
Remote Method Invocation (Java)
All ports below 1024 are well known, used for standard services
Q&A
Thank you