Page 353 - DCAP103_Principle of operating system
P. 353
Principles of Operating Systems
Notes Introduction
A thread is the entity within a process that can be scheduled for execution. All threads of a
process share its virtual address space and system resources. In addition, 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. The thread
context includes the thread’s set of machine registers, the kernel stack, a thread environment
block, and a user stack in the address space of the thread’s process. Threads can also have their
own security context, which can be used for impersonating clients.
Microsoft Windows supports preemptive multitasking, which creates the effect of simultaneous
execution of multiple threads from multiple processes. On a multiprocessor computer, the
system can simultaneously execute as many threads as there are processors on the computer.
12.1 Processes and Threads in Windows 2000
Windows 2000 has a number of concepts for managing the CPU and grouping resources together.
In the following sections we will examine these, discussing some of the relevant Win32 API
calls, and show how these concepts are implemented.
12.1.1 Fundamental Concepts of Process and Threads in Windows 2000
Windows 2000 supports traditional processes, which can communicate and synchronize with
one another, just as they can be in UNIX. Each process contains at least one thread, which in
turn contains at least one fiber (lightweight thread). Furthermore, processes can be collected into
jobs for certain resource management purposes. Together, jobs, processes, threads, and fibers
provide a very general set of tools for managing parallelism and resources, both on uniprocessors
(single-CPU machines) and on multiprocessors (multi CPU machines). A brief summary of these
four concepts is given in Figure 12.1.
Figure 12.1: Basic Concepts Used for CPU and Resource Management
Name Description
Job Collection of processes that share quotas and limits
Process Container for holding resources
Thread Entity scheduled by the kernel
Fiber Lightweight thread managed entirely in user space
Let us examine these concepts from the largest to the smallest. A job in Windows 2000 is a
collection of one or more processes that are to be managed as a unit. In particular, there are
quotas and resource limits associated with each job stored in the corresponding job object. The
quotas include items such as the maximum number of processes (prevents any process from
generating an unbounded number of children), the total CPU time available to each process
individually and to all the processes combined, and the maximum memory usage, again, per
process and total. Jobs can also impose security restrictions on the processes in the job, such
as not being able to acquire administrator (superuser) power, even with the proper password.
Processes are more interesting and also more important than jobs. As in UNIX, processes are
containers for resources. Every process has a 4 GB address space, with the user occupying the
bottom 2 GB (optionally 3 GB on Advanced server and Datacenter server) and the operating
system occupying the rest. Thus the operating system is present in every process’ address,
346 LOVELY PROFESSIONAL UNIVERSITY