(0) A thread is a unit (or sequence of code) that can be executed by a scheduler, essentially a task (Sanden, 2011). A single thread (task) will have one program counter and a sequence of code. Multi-threading occurs when one program counter shares a common code. Thus, the counter in multi-threading has many sequences of code that can be assigned to different processors to run in parallel (simultaneously) to speed up a task. Another way for multi-threading is to have the counter execute the same code on different processors with different inputs. If data is shared between the threads, there is a need for a “safe” object through synchronization, where one thread can access the data stored in a “safe” object at one time. It is through these “safe” objects that a thread can communicate with another thread.
(1) Sanden (2011) shows to use synchronized objects (concurrency in Java), which is a “safe” object, that are protected by locks in critical synchronized methods. Through Java we can create threads by: (1) extend class Thread or (2) implement the interface Runnable. The latter defines the code of a thread under a method: void run ( ), and the thread completes its execution when it reaches the end of the method (which is essentially like a subroutine in FORTRAN). Using the former you need the contractors public Thread ( ) and public Thread (Runnable runObject) along with methods like public start ( ).
(2) Shared objects force mutual exclusion on threads that try to call it are “safe objects”. The mutual exclusion on threads/operations can be relaxed when threads don’t change any data, this may be a read of the data in the “safe object” (Sanden, 2011).
(3) Deadlock occurs while you are getting an additional resource while holding another or more resource, especially when it creates a circularity. To prevent deadlocks, resources need to be controlled. One should do a wait chain diagram to make sure your design can help prevent a deadlock. Especially when there is a mix of transactions occurring. A good example of a deadlock is a stalemate in Chess or as Stacy said, a circular firing squad.
(4) In a distributed system nodes can talk (cooperate) to each other and coordinate their systems. However, the different nodes can execute concurrently, there is no global clock in which all nodes function on, and some of these nodes can fail independently. Since nodes talk to each other, we must study them as they interact with each other. Thus, a need to use logical clocks (because we don’t have global clocks) which show that distances in time are lost. In logical clocks: all nodes agree on an order of events, partially (where something can happen before another event). They only describe the order of events, not with respect to time. If nodes are completely disjoint in a logical clock, then a node can fail independently. (This was my favorite subject because I can now visualize more about what I was reading and the complex nature of nodes).
(5) An event thread is a totally ordered sequence of event occurrences, and where a control thread processes each occurrence in turn. In the event thread, we can have 2 occurrences act in either:
- x — > y
- y — >
- x || y
Events in this thread must be essential to the situation they are being used for and independent of any software design. Essential threads can be shared like by time, domain, or by software, while others are not shared, as they occur inside the software.
- Sandén, B. I. (2011-01-14). Design of Multithreaded Software: The Entity-Life Modeling Approach, 1st Edition. [VitalSource Bookshelf Online]. Retrieved from https://bookshelf.vitalsource.com/#/books/9781119143086/