1. Find definitions for eight terms and concepts used in threaded programming:
1. Thread Synchronisation: this is process which will block a thread which is trying to access to resource that is being accessed by other thread. The blocking process will end until resource is free. This process helps to prevent deadlock when 2 thread access to the same resource at the same time.
2. Locks: is defined as a method which has function to block threads accessing to resource to avoid deadlock when there are many threads try to accessing to the same resource at the same time.
3. Deadlock: is refer to specific condition when two processes or more are waiting in chain for accessing the resource. This happen often in multiprocessing where many processes have to share specific resources.
4. Semaphores: it is a process that allows many processes can access to resource at the same time. In addition, it is integer that is changed after each process access to the resource.
5. Mutex (mutual exclusion): according to Wikipedia is an object which has function to help avoid two events not to occur at the same time (when two process access resource) by using critical sections.
6. Thread: a thread of execution results from a separation of a computer program into two running tasks. In addition, process contains thread or multithreads which and share a resource such as memory (but multiprocessors do not share a same resource).
7. Event: Wikipedia mentions that event is something that is initiated outside the scope of a program which is handled by a piece of code inside the program. Furthermore, it is often used in user interface such as pressing a key on the keyboard.
8. Waitable timer: according to MSDN mentions that object which has state is set to be signaled when the due time arrive, we call this is waitable timer object. In addition, there are two types of waitable timer that can be created: manual-reset timer, synchronization timer and either way of these two is periodic timer.
2. A simple demonstration of the threading module in Python (threaddemo.py) that uses both a lock and semaphore to control concurrency is by Ted Herman at the University of Iowa. The code and sample output below are worth a look. Report your findings.
What we finding are:
Semaphore in this program has limit module running 3 tasks at the same time.
These tasks will run continuously after each one done.
The mutex script with “RLock” has function get an update the process on semaphore.
Sema.release() will release the task to let another running continuously.
References
MSDN (2009). Waitable Timer Objects. Retrieved 15 October 2009 from http://msdn.microsoft.com/en-us/library/ms687012%28VS.85%29.aspx
Threads and Locks(2005). Retrieved 15 October 2009 from http://java.sun.com/docs/books/jls/third_edition/html/memory.html
Wikipedia (n.d.).Deadlock. Retrieved 15 October 2009 from http://en.wikipedia.org/wiki/Firewall
Wikipedia (n.d.). Mutual exclusion. Retrieved 15 October 2009 from http://en.wikipedia.org/wiki/Mutual_exclusion
Wikipedia (n.d.). Thread. Retrieved 15 October 2009 from http://en.wikipedia.org/wiki/Thread_%28computer_science%29
Wikipedia (n.d.). Event. Retrieved 15 October 2009 from http://en.wikipedia.org/wiki/Event_%28computing%29
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment