Process, Threads and Synchronization

Given n, print numbers from zero to n sequentially using two threads such that one thread prints only odds and other prints only evens.

This is a simple classical thread synchronization problem. Before moving to the solution I would like revise basic process, thread, and synchronization/concurrency concepts. Some of the figures in this article are taken from this Silberschatz OS book.

Permutation and Combination

Permutation

Permutation means arranging all the members of a set into some sequence or order, or if the set is already ordered, rearranging (reordering) its elements, a process called permuting. These differ from combinations, which are selections of some members of a set where order is disregarded. For example, written as tuples, there are six permutations of the set {a,b,c}, namely: (a,b,c), (a,c,b), (b,a,c), (b,c,a), (c,a,b), and (c,b,a). These are all the possible orderings of this three element set.