CST334.5 Module Five

 

CST334.5 Module Five

What I learned this week:

This week we were introduced to concurrency and the use of Threads within a multi-threading program. Where threads hold similar properties of processes such as control blocks (TCB's), they also act similarly in context switches. One major distinction is that threads within the same process share the same address space, although each thread has a stack associated with. Threads enable Parallelism, and also enable overlap of I/O with other activities within their program. The most glaring problem with threads though is without some sort of synchronization, updates. and reads to shared variables or even physical memory becomes indeterminate. So in order to address this, the need to highlight critical sections within the program and provide mutual exclusion for the specified sections is mandatory, providing atomicity thus making the program deterministic in its outputs.

We also learned some synchronization primitives provided by hardware which aid in supporting atomicity. Two notable primitives being locks and conditional variables as they provide hardware support which remove the need of context switching to drop into and out of kernel mode. Locks are just variables which encompass a state of being either available or acquired. If a thread is granted control of the lock, they are capable of entering into their critical section while other threads wishing control of the lock are held until release of the lock (after critical section is exited). This provides mutual exclusion for the critical section. Conditional variables are an explicit queue that threads can place themselves in when something is not as desired. one of the key tips when using Conditional variables is to hold the lock when signaling or waiting with the synchronization primitives, this ensures that the critical section has been completed atomically.

Comments

Popular Posts