Lecture 24

SFR1811·2022년 4월 1일
0

CS343-Parallel Programming

목록 보기
21/24

In uC++, S(signaller) > W(signalled) > C(calling)


This is not a uC++ scheduler

  1. We can optimize and get rid of the queue for S.
  2. W is a stack instead of a queue
    • if you call multiple signals from conditions, it will be executied in reversed order.

9.3 Increasing Concurrency

How to maximise concurrency?
How do we reduce the number of blockings and sequencial codes?

Terminology:
- client: caller
- server: callee

9.3.1 Server Side

When using Task as scheduling, move as much code to the main() of the Task as possible.

Currently there is only 1 slot for mem functions.
So this task is a buffer of size 1.

If a buffer of size 1 is good, buffer of size N maybe better.
i.e. allow many clients to make requests to the server without blocking other clients

9.3.1.1 Internal Buffer

problems
1. If you want to create a buffer, careful so that the buffer is not always full or empty
2. mutex problems.

  • the previous approches worked because there were no clients calls accepted until the server is done working.
  • also the client may need to wait until it gets the result
  • so the full time person - thread - cannot manage client arriving & leaving and working at the same time

The only way to get out of this is to create more threads!

  • Threads that manage interactions between client, server, worker
  • so instead of just having server, lets have worker and server
  • Client - Server - Worker

9.3.1.2 Administrator

an administrator is a server managing multiple clients and worker tasks.

It does little or no "real" work; its job is to manage.

Management means:

  • delegateign work to others
  • and receiving and checking completed work
  • and pass completed jobs

Administrator makes no call
If you call, you can be blocked

Admin can have buffers for gathering and returning data or banches for workers to wait on.

Diagram analysis

notifier:

  • calls event and blocks until some event occurs, i.e. key press
  • when event occurs, it calls the admin to notify that the event occured

timer:

  • notifies admin at perticular time

worker_simple:

  • simple workers. they are only allowed to talk to admin
  • calls admin and checkes if there is any work
    • if there is, take it and returns the result to the admin
      • but its inefficient because you need to call twice, to get the work, and to return the result
      • so make it so that worker returns the result is passed to the admin as an argument, and the worker gets a work as a result.
      • first call to the admin will pass the admin a empty result
    • if there is no work, worker sits on the bench of in the admin.

worker_complex:

  • complex workers. they are allowed to talk to another client during working

courier:

  • mediates calls between admins
  • courier calls admin to notify that the admin has a incoming calls

the Admin may want to use signalBlock when returning the calls so that the callers can exit admin

The system is deadlock free :)

profile
3B CS

0개의 댓글