0% found this document useful (0 votes)
13 views33 pages

6 - Concurrent Processes (v2)

The document discusses different types of parallel processing configurations including master-slave, loosely coupled, and symmetric configurations. It also covers techniques for process synchronization such as test-and-set, wait-and-signal, and semaphores.

Uploaded by

22004788
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)
13 views33 pages

6 - Concurrent Processes (v2)

The document discusses different types of parallel processing configurations including master-slave, loosely coupled, and symmetric configurations. It also covers techniques for process synchronization such as test-and-set, wait-and-signal, and semaphores.

Uploaded by

22004788
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/ 33

Concurrent Processes

WXES1110 (6) 1
Analogy (1)
 You drive to KFC drive-through window.
 When you place your order, the order clerk
confirms your request, tells you how much it
costs and ask you to drive to the pick-up
window.
 At the pick-up window, the cashier collects
your money and hands over your order.
 This is a synchronised multiprocessing
system.

WXES1110 (6) 2
Analogy (2)
 You come into contact with 2 processors –
the order clerk and the cashier.
 There are at least 2 more processors to
make the system work – the cook and the
bagger.
 Compare the scenario to an information
retrieval system.
 Processor 1 (order clerk) accepts the query,
checks for errors, and passes the request to
Processor 2 (bagger).
WXES1110 (6) 3
Analogy (3)
 Processor 2 searches the database for the
required info (hot & spicy chickens).
 Processor 3 (cook) retrieves data from the
database (chicken to cook) if it’s kept
offline in secondary storage. Once data is
gathered (chicken is cooked), it is placed
where Processor 2 can get it (in the chicken
bin).
 Processor 2 passes it to Processor 4
(cashier).

WXES1110 (6) 4
Analogy (4)
 Processor 4 routes the response (your
order) back to the originator of the request
(you).

WXES1110 (6) 5
What is Parallel Processing? (1)
 Parallel processing or multiprocessing is a
situation in which two or more processors
operate in unison.
  2 processors execute instruction
simultaneously.
 The Processor Mgr has to coordinate the
activity of each processor and synchronise
the interaction among the CPUs.

WXES1110 (6) 6
What is Parallel Processing? (2)
 Synchronisation is a key factor in the
success of multiprogramming systems.
 A system will only work properly if every
processor communicates and cooperates
with every other processor.
 2 major reasons behind multiprocessing:
 Enhance throughput;
 Increase computing power.

WXES1110 (6) 7
What is Parallel Processing? (3)
 2 benefits: increased reliability and faster
processing.
 The benefits are achieved by careful
design.
 The failing processor can inform other
processor(s) to take over;
 The OS can restructure its resource
allocation strategies so that remaining
processors don’t become overload.

WXES1110 (6) 8
What is Parallel Processing? (4)
 A few ways to allocate the CPU:
 Allocate a CPU to each job;
 Allocate a CPU to each working set;
 Subdivide individual instructions and each
subdivision is processed simultaneously.
 Increased flexibility brings increased
complexity. 2 challenges:
 How to connect the CPUs into
configurations;
 How to orchestrate their interaction.

WXES1110 (6) 9
Typical Multiprocessing
Configurations
 Master/slave configuration
 Loosely coupled configuration
 Symmetric configuration

WXES1110 (6) 10
Master/Slave Configurations (1)
 Is an asymmetric multiprocessing system.
 Is a single-processor system with additional
slave processors, each is managed by the
primary master processor.
 The master processor is responsible for
managing the entire system.
 Suitable for an environment where the
processing time is divided btwn front-end
and back-end processors.

WXES1110 (6) 11
Master/Slave Configurations (2)

WXES1110 (6) 12
Master/Slave Configurations (3)
 Advantage: simple.
 Disadvantages:
 The reliability is not much better than a
single processor system.
 Can lead to poor utilisation of resources.

 Increased number of interrupts.

WXES1110 (6) 13
Loosely Coupled Configuration (1)
 Several complete computer systems, each
with its own memory, I/O devices, CPU and
OS.
 Loosely coupled because each processor
controls its own resources.
 Each processor can communicate and
cooperate with the others.

WXES1110 (6) 14
Loosely Coupled Configuration (2)

WXES1110 (6) 15
Loosely Coupled Configuration (3)
 When a job arrives:
 It is allocated to one processor.
 It remains with the same processor until it
finishes.
 The job scheduling algo keeps the system
well-balanced and ensures the best use of
resources using several requirements and
policies.
 E.g. new jobs are assigned to the processor
with the lightest load.
WXES1110 (6) 16
Symmetric Configuration (1)
 Is best implemented if all processors are of
the same type.
 Advantages over loosely coupled config:
 More reliable;
 Uses resources effectively;

 Can balance loads well;

 Can degrade gracefully in the event of


failure.

WXES1110 (6) 17
Symmetric Configuration (2)

WXES1110 (6) 18
Symmetric Configuration (3)
 Is the most difficult config to implement
because processes must be well
synchronised to avoid races and deadlocks.
 Process scheduling is decentralised.
 There is one copy of the OS.
 Each processor has access to a global table
listing each process and its status that is
stored in a common area of the memory.

WXES1110 (6) 19
Symmetric Configuration (4)
 Processors use the same scheduling algo.
 When a process is interrupted, its
processor updates the corresponding entry
in the process list and finds another
process to run.
 Since each processor has access to all I/O
devices and can reference any storage unit,
there are more conflicts when several
processors try to access the same
resources – requires algo to resolve
conflicts.
WXES1110 (6) 20
Process Synchronisation Software (1)

 Process synchronisation depends on the


capability of the OS to make a resource
unavailable to other processes while it is
being used by one of them.
 A used resource is locked from other
resources until it is released – only then can
a waiting process be allowed to use the
resource.
 Synchronisation is important because a
mistake could leave a job waiting
indefinitely or lead to a deadlock.
WXES1110 (6) 21
Process Synchronisation Software (2)

 Example: Processor 1 and Processor 2 finish


their job executions at the same time. To
run the next job, each processor must:
 Consult the list of jobs to see which one
should run next.
 Retrieve the job for execution.

 Increment the READY list to the next job.

 Execute it.

WXES1110 (6) 22
Process Synchronisation Software (3)

 Other resources where the same problem


can occur: memory and page allocation
tables, I/O tables, application databases,
any shared resources.
 A synchronisation mechanism is required to
provide cooperation and communication
among processes.
 Allows a process to finish work on a critical
region of a program before other processes
have access to it.
WXES1110 (6) 23
Process Synchronisation Software (4)

 A critical region is a part of a program that


must complete execution before other
processes can have access to the resources
being used.
 Synchronisation can be implemented using a
lock-and-key scheme.
 A process checks to see if a key is available.
 If it is available, the process picks it up and
put it in the lock to make the resource
unavailable to other processes.
WXES1110 (6) 24
Process Synchronisation Software (5)

 There are several locking mechanisms:


 Test-and-Set
 WAIT and SIGNAL

 Semaphores

WXES1110 (6) 25
Test-and-Set (1)
 Is an indivisible machine instruction known
as TS.
 It tests to see if the key is available. If it
is, it sets it to unavailable.
 The key is a single bit in a storage location
whose value is 0 if it is free; 1 if it is busy.
 TS has one parameter (the storage location)
and returns one value (busy/free). It takes
only one machine cycle.

WXES1110 (6) 26
Test-and-Set (2)
 Process 1 (P1) tests the condition code using
the TS instruction before entering a
critical region.
 If no other process is in the critical region,
P1 is allowed to proceed and the condition
code is changed from 0 to 1.
 When P1 exits the critical region, the
condition code is reset to 0 so another
process can enter.

WXES1110 (6) 27
Test-and-Set (3)
 If P1 finds a busy condition code, it is placed
in a waiting loop where it continues to test
the condition code and waits until it is free.
 Test-and-Set is simple to implement and
works well for a small number of processes.

WXES1110 (6) 28
Test-and-Set (4)
 2 drawbacks:
 When many processes are waiting to enter a
critical region, starvation could occur
because processes gain access in an
arbitrary fashion.
 Waiting processes remain in unproductive,
resource-consuming wait loops, known as
busy waiting.

WXES1110 (6) 29
WAIT and SIGNAL (1)
 Is a modification of Test-and-Set to
remove busy waiting.
 Consists of 2 operations that are mutually
exclusive: WAIT and SIGNAL.
 WAIT is activated when the process
encounters a busy condition code.
 It sets the process’s PCB to a blocked state
and links it to the queue of processes waiting
to enter the critical region.
 The Process Scheduler selects another
process for execution.
WXES1110 (6) 30
WAIT and SIGNAL (2)
 SIGNAL: is activated when a process exits
the critical regions and the condition code
is set to free.
 It checks the queue for processes waiting to
enter the critical region, selects one and
sets it state to READY.
 Eventually, the Process Scheduler will
choose this process for running.

WXES1110 (6) 31
Semaphores (1)
 Is a flag that has a non-negative integer
value.
 Analogy: flag-like signaling used by railroads
to indicate whether the track is clear.
 In an OS, a semaphore signals if and when a
resource is free and can be used by a
process.

WXES1110 (6) 32
Group discussion
 Give an example from real life of busy
waiting.

WXES1110 (6) 33

You might also like