The notion of a process proceeded the notion of a thread by many years. A thread wasn't considered a fundamental operation system object until ~1992. Requiring WinNT and a holy war between Unix vendors. All out of business so it safe now: yes, a process has at least one thread.
–
Hans PassantOct 1 '11 at 23:13

1

So in general, would a zero thread process essentially be a finite state machine?
–
rrazdOct 1 '11 at 23:14

5 Answers
5

A process usually has at least one thread. Wikipedia has the definition:

a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process.

You can choose not to use an explicit threading library, or an operating system that has no concept of threads (and so doesn't call it a thread), but for most modern programming all programs have at least one thread of execution (generally referred to as a main thread or UI thread or similar). If that exits, so does the process.

Thought experiment: what would a process with zero threads of execution do?

In theory, I don't see why not. But it would be impossible with the popular operating systems.

A process typically consists of a few different parts:

Threads

Memory space

File discriptors

Environment (root directory, current directory, etc.)

Privileges (UID, etc.)

Et cetera

In theory, a process could exist with no threads as an RPC server. Other processes would make RPC calls which spawn threads in the server process, and then the threads disappear when the function returns. I don't know of any operating systems that work this way.

On most OSs, the process exits either when the last thread exits, or when the main thread exits.

Note: This ignores the "useless" cases such as zombie processes, which have no threads but don't do anything.