Wednesday, January 10, 2018

Session 10

Session 10
Saturday, 6 January 2018

Miss Yanni has business on 9 december and decided to change the class date to 6 january 2018 from 9 december 2017. Today session talks about concurrency. 

Concurrency can occur at four levels:
  • Machine instruction level.
  • High-level language statement level.
  • Unit level.
  • Program level.
A task/process/thread is a program unit that can be in concurrent execution with other program units. Tasks usually work together. There're 2 general categories of tasks, such as Heavyweight tasks and lightweight tasks. Heavyweight tasks execute in their own address space and lightweight tasks all run in the same address space - more efficient. A task is disjoint if it does not communicate with or affect the execution of any other task in the program in any way. 


A mechanism that controls the order in which tasks execute is called task synchronization. There's 2 kind of synchronization : cooperation synchronization and competition synchronization. Cooperation synchronization means task A must wait for task B to complete specific activity before task A can continue its execution. Competition synchronization means two or more tasks must use some resource that cannot be simultaneously used. For task synchronization, task communication is necessary and provided by shared nonlocal variables, parameters, and message passing.

Providing those 2 synchronization requires a mechanism for delaying task execution. Those task execution control is maintained by a program that is called the scheduler. 

Task execution states :
  • New - created but not yet started
  • Ready - ready to run but not currently running (no available processor)
  • Running 
  • Blocked - has been running, but cannot now continue (usually waiting for some event to occur)
  • Dead - no longer active in any sense

A characteristic that a program unit may or may not eventually complete its execution is called liveness. If all tasks in a concurrent environment lose their liveness, it is called deadlock.

Methods of providing synchronization are semaphores, monitors, and message passing. 

Semaphore is a data structure consisting of a counter and a queue for storing task descriptors(data structure that stores all of the relevant information about the execution state of the task).

Monitor is an abstract data type for shared data. Message passing is a general model for concurrency.

That's all for this session.

No comments:

Post a Comment