Friday, 17 September 2010

Processes and Threads

A 'process' is an 'instance' of a 'computer program' that is being 'executed'. It contains the 'program code' and its 'current activity' (state?).

A 'thread of execution' is the smallest unit of 'processing' that can be scheduled by an operating system. It generally results from a 'fork' of a computer program into two or more concurrently executing 'tasks'. Typically, a thread or multiple threads are contained inside a process and share resources such as state and memory.

An advantage/use of multi-threading: the ability for an application to remain responsive to input, e.g. in a single threaded program, if the main execution thread blocks on a long running task, the entire application can appear to freeze. By moving such long running tasks to a worker thread that runs concurrently with the main execution thread, it is possible for the application to remain responsive to user input while executing tasks in the background.

No comments: