Unit Tests

Unit testing is a form of software testing where you test small individual “units” of code. Each unit tested might be associated with a small sub-section, like a function. The associated control data, usage procedures, and operating procedures, are tested to determine whether the unit is ready for use, or at least the next set…

Multi-Tier Applications

Object oriented languages do a good job of helping you learn to separate out the process of working with different data elements. This concept can be extended to get you toward an important software development concept: multi-tier applications. In the “old days” a program would pull data from a data source, store that information, perform…

Deadlock Detection

A deadlock in a resource allocation graph can be detected by executing a graph reduction algorithm by repeating this process: Select an unblocked process p. Remove p, including all request and allocation edges connected to p. Anything left is blocked, and risks deadlock. However, it is considered completely reducible if there are no processes left…

A System Model for Deadlocks

A resource allocation graph shows the current allocation of resources to processes and the current requests by processes for new resources. Processes are represented by circles. Resources are represented by rectangles. Small circles designate multiple units within a resource. Resource allocations are represented by edges directed from a resource to a process. Resource requests are represented by…

Classic Synchronization Problems

The Readers-Writers Problem The readers-writers problem is an extension of the critical section problem where two types of processes, readers and writers. However, it involves an interesting issue when the processes compete for access to a common resource. Multiple readers are allowed to enter the critical section concurrently but only one writer is allowed to…

Monitors

P and V operations on general semaphores are versatile primitives capable of solving a variety of synchronization problems. But they are low-level primitives, prone to difficult-to-diagnose programming errors. (see the issues that we need to avoid in Process Interactions – those are some of the errors you might run into.) A monitor is a high-level synchronization primitive…

The Implementation of Semaphores

Most contemporary computer architectures offer hardware support for process synchronization in the form of specialized machine instructions. The test-and-set instruction (TS) copies a variable into a register and sets the variable to zero in one indivisible machine cycle. Test-and-set has the form TS(R, x) where R is a register and x is a memory location and performs…