Monday, April 27, 2009

Exercise 17: Concurrency terms

Find definitions for eight terms and concepts used in threaded programming:
1. Thread Synchronisation
2. Locks
3. Deadlock
4. Semaphores
5. Mutex (mutual exclusion)
6. Thread
7. Event
8. Waitable timer.


1. Thread Synchronisation
A thread may execute process with multipe objects, as well as multiple threads may attempt to execute processes that involve a single object. Thread synchronisation is a process by which threads interact to check the status of objects (Bak, 2000). In thread applications, synchroize individual threads with other parts of program is needed. The unstructured nature of multithreaded programming and the structured order of synchronous processing are compromised by Thread synchronisation (MSDN, N.A.).

2. Locks
An object may accesses by multiple threads, to prevent all but one thread from executing a process to an particular object. Locked is involves to allow only one thread is permitted to operate on that object. (Bak, 2000). Most server software provide two types of locks for optimize the locking process, they are read lock and write lock (Ince, 2002).

Flowchart of object locking (Bak, 2000):
  • step 31: threaddetemines whether the object is locked
  • step 33: current thread get exclusive access rights to the object
  • step 34: the object was locked by current thread previously
  • step 35: the object locking process stop
  • step 37: the object was locked by other thread, the current thread waits for the object to be unlocked before continuing


3. Deadlock
Deadlock is two or more threads are waiting for one another to be finish (or unlock), but neither ever does. The threads may waiting for object lock in a circular chain. The object lock to guarantees exclusive access to processes. Deadlocks are a commonly troubling as there is no general solution to avoid (Wikipedia I, N.A.).

4. Semaphores
Semaphore is a protected variable or abstract data type which make up the method for limiting the access of sharing resources such as shared memory in a multiprogramming environment (Wikipedia II, N.A.).

5. Mutex (mutual exclusion)
Mutex is the short term for mutual exclusion. An object that allows multiple threads to share the same resource not at the same time is called mutex. When a program start, a mutex is generated with a unique name. Any thread that needs the resource of the object must lock the mutex from other threads while it is using the resource. The mutex is set to unlock state during the data is no longer needed or the process is finished (Webopedia, N.A.).

6. Thread
Thread is a sequential spread of control within a program. Each thread has its own execution stack where method activation reside. Threads can either be cooperative or concurrent running in a system (Bak, 2000). Threads also called lighweight processes and are likely to forking a process. As multiple threads of a process utilizes the same address space (all static and external data, open files are shared), can make parallel programming easier. Threads are used when need to protect shared resources or synchronise resources. Threads exist in modern operating systems software like UNIX, Microsoft Office (Eustace 2009).

7. Event
Event is the simplest mechanisms for communication between threads. If a thread signals an event and other threads will wait for it. An event object manages is an changeable internal flag (Python, 2005).

8. Waitable timer
Waitable timer is a synchronization object. Its state is set to signaled when a specified due time reach (Mischel, 2009).

Reference
  1. Bak, L. (2000), Thread synchronization in a computer controlled by an object-based, Sun Microsystems, Inc.
  2. Eustace, K. (2009), E-systems infrastruction development - itc594 study guide, CSU.
  3. Ince, D. (2002), Developing distributed and e-commerce applications, 2nd edition, Addison-Weskey.
  4. Mischel, J. (2009), Waitable timers in .net with c#, DevSource, Retrieved at http://www.devsource.com/c/a/Languages/Waitable-Timers-in-NET-CSharp/ on 28th April, 2009.
  5. MSDN (N.A.), Thread synchronization, Microsoft, Retrieved at http://msdn.microsoft.com/en-us/library/dsw9f9ts.aspx on 28th April, 2009.
  6. Python (2009), Python library reference - event objects, Python, Retrieved at http://www.python.org/doc/2.3.5/lib/event-objects.html on 28th April, 2009.
  7. Webopedia (N.A.), Mutex, Webopedia, Retrieved at http://www.webopedia.com/TERM/M/mutex.htmlon 28th April, 2009.
  8. Wikipedia I (N.A.), Deadlock, Wikipedia, Retrieved at http://en.wikipedia.org/wiki/Deadlock on 28th April, 2009.
  9. Wikipedia II (N.A.), Semaphore (programming), Wilipedia, Retrieved at http://en.wikipedia.org/wiki/Semaphore_%28programming%29 on 28th April, 2009.

No comments:

Post a Comment