Process and Thread

871 Words2 Pages

When an executable file is loaded into memory, it is called a process. A process is an instance of a program in executing. It contains its current activity, such as its program code and also the contents of the processor’s register. It generally includes the process stack, which contain temporary data, and a data section, which global variables. During runtime, it may include a heap, or dynamically allocated memory. In contrast with a program, a process is “an active entity, with a program counter specifying the next instruction to execute and a set of associated resources” (Operating System Concept 106). A process is a program that executes a single instance of a thread. Multiple threads can exist which allows more than one task to perform at a time. Multithreaded processes may share resources such as code, data, and file section. They do not share resources such as registers and stack.
According to Microsoft, the simplest definition of a process is an executed program. A thread is “the basic unit to which the operating system allocates processor time”. A thread can “execute any part of the process code, including parts currently being executed by another thread”. In Windows, threads share its virtual address space and system resources. Unlike the conceptual model, each thread “maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier and a set of structures the system will use to save the thread context until it is scheduled”. Like the conceptual model of a thread, Windows’ threads do not share registers and stack resources. This is because the thread context includes “the thread’s set of machine registers, the kernel stack, a thread environment lock and a user stack in the address sp...

... middle of paper ...

... to a session, a process group leader is “the process whose pid is the same as its process group ID”. On creation, a process becomes a member of its parent’s process group. A session contains a number of process groups. When a user logs out of the system, the kernel must be able to terminate all the processes it had running. Otherwise, the system will wait for inputs that will never come. To help with this task, processes are grouped into sessions. Every process group is in a unique session. On creation, a process becomes a member of its parent’s session. The session’s ID is “the same as the pid of the process that created the session through the setsid() system call” (Johnson and Troan). The session leader contains all of the process’ descendants unless the process is removed from the session. The setsid() returns the new session ID and does not take any arguments.

Open Document