Data Analysis is the process of systematically applying statistical and/or logical techniques to describe and illustrate, condense and recap, and evaluate data.
3. Lecture Outcomes
• Understanding of:
• the notion of a process -- a program in execution, which forms the basis of all
computation
• the various features of processes, including scheduling, creation and
termination, and communication
• Inter-process communication using shared memory and message passing
5. Cooperating Processes
● Processes within a computer system may be independent or cooperating.
● Independent Process
● Cannot affect or be affected by the execution of another process.
● Cooperating Process
● Can affect or be affected by other processes, also includes the sharing data.
● Cooperating processes need interprocess communication (IPC).
6. Interprocess Communication (IPC)
● Reasons for cooperating processes:
• Several users may be interested in the same piece of
information (e.g. a shared file).
Information
Sharing
• If speedup the processing of a task, break it into subtasks,
so each can be executed in parallel.
Computation
Speedup
• Construct system in modular fashion, dividing the system
functions into separate processes.
Modularity
Convenience
•Allow individual user to work on many tasks at the same
time.
8. Shared-Memory
● A region of memory that is shared by the cooperating processes is established.
● This region usually resides in the address space of the process that is creating it.
● The processes can then exchange information by reading and writing data to the shared
region.
OS (Kernel)
Process A
Process B
Main Memory
Shared
Memory
9. Shared-Memory
● Typically, the producer-consumer problem is often used to explain the shared-memory
model.
● Similar to the paradigm of cooperating processes, where producer (a process) produces
information that will be consumed by a consumer (another process).
Buffer
(Shared Memory)
Produce
r
Consume
r
Process A
Process B
12. Shared-Memory
●The producer and the consumer must be synchronized.
● Two cooperating processes must be synchronized.
●Consumer should not consume an item that has not been produced by the producer.
● A process should not read the data until it has been produced (or updated) by another
process.
13. Message Passing
● Another mechanism for processes to communicate.
● The message passing facility provides at least two operations:
● send(message)
● receive(message)
● Message can be in fixed or variable size.
14. Message Passing
● If message is in fixed size:
● Easier for system implementation.
● Harder for programmer.
● If message is in variable size:
● Harder for system implementation
● Easier for programmer.
16. Message Passing Model
● When processes want to communicate, they need to:
1) Establish a communication link between them.
2) Exchange messages via the send or receive operation.
● Two types of communication:
1) Direct Communication
2) Indirect Communication
17. 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.
● Between each pair of processes there exists exactly one link.
● The link is usually bi-directional.
● Disadvantages:
● Must know the name (ID) of the process that is going to send or receive the message
(hard-coding is not desirable)
18. Indirect Communication
● Messages are sent to and received from mailboxes or 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.
19. Indirect Communication
● To communicate using indirect communication:
1) Create a new mailbox.
2) Send and receive messages through mailbox
3) Destroy the mailbox.
● Processes do not have to name each other explicitly:
● send(A, message):
● Send a message to mailbox A.
● receive(A, message):
● Receive a message from mailbox A.
20. Indirect Communication
● Assuming that we have three processes, P1, P2, and P3 that sharing the mailbox A.
If P1 sends a message, then P2 and P3 run receive from A. Who gets the message?
● It depends on how the OS want to handle it.
1) Allow a link to be associated with at most two processes
2) Allow only one process at a time to execute a receive operation.
3) Allow the system to select arbitrarily the receiver.
● Sender will be notified who was the receiver.
21. Direct and Indirect Communication
● Direct Communication
● Indirect Communication
P Q
To
Q
From P
P Q
R
Mailbox
A
To A
From A
From A
22. Implementation of Message Passing
Blocking (Synchronous) Non-blocking (Asynchronous)
Blocking Send:
Sender is blocked until the message is
received by the receiving process or by
the mailbox.
Non-blocking Send:
Sender sends the message and resumes
operations.
Blocking Receive:
Receiver is blocked until a message is
available.
Non-blocking Receive:
Receiver can retrieve either a valid
message or a null.
23. Synchronous (Blocking Send)
Sender Receiver
1. send(“I’m hungry”) Sending…
Can I send
another
message?
NO
Suspende
d
Ya, I received and
read your
message.
Done
OK
2. send(“Lunch?”)
Have to wait for confirmation from the receiver.
24. Synchronous (Blocking Receive)
Sender Receiver
send(“I’m hungry”) Waiting
…
Suspende
d
Can I back off and
do other things?
NO
Done OK
Have to wait until there is a message to receive.
receive(Sender)
27. Buffering
● Messages exchanged by processes reside in a temporary queue (buffer).
● Basically, the queue can be implemented in three ways:
1. Zero Capacity – Zero Messages
● The link cannot have any messages waiting in it.
● The sender needs to block until the recipient receives the message.
2. Bounded Capacity – Finite Length of n Messages
● If the queue not full, sender places the message in the queue.
● Sender can then continue execution without waiting.
● If the queue is full, sender has to block.
3. Unbounded Capacity – Infinite Length of Messages
● Sender will never blocks.
28. Shared-Memory v.s. Message Passing
Shared-Memory Message Passing
Faster in exchanging data. System calls
are required to establish the shared-
memory regions. Once is established, no
assistance is needed from the kernel.
Useful for exchanging smaller amount of
data. Slower because typically it is
implemented using system calls that
requires kernel intervention.
Convenience for communication within
the same system.
Easier to implement for intercomputer
communication.
29. Review Questions
• Provide at least three possible states a process may be in.
• What is a Process Control Block (PCB) ?
• What is the degree of multiprogramming?
• What is the term that describes saving the state of one process, and
restoring the state of another?
• What system call creates and terminates a process on UNIX systems
and Windows systems?
• What are the two system calls used with message-passing systems?