Hardware Reference
In-Depth Information
managing parallelism, both on uniprocessors (single-CPU machines) and on multi-
processors (multi-CPU machines).
New processes are created using the API function CreateProcess . This func-
tion has 10 parameters, each of which has many options. This design is clearly a
lot more complicated than the UNIX scheme, in which fork has no parameters, and
exec has just three: pointers to the name of the file to execute, the (parsed) com-
mand-line parameter array, and the environment strings. Roughly speaking, the 10
parameters to CreateProcess are as follows:
1. A pointer to the name of the executable file.
2. The command line itself (unparsed).
3. A pointer to a security descriptor for the process.
4. A pointer to a security descriptor for the initial thread.
5. A bit telling whether the new process inherits the creator's handles.
6. Miscellaneous flags (e.g., error mode, priority, debugging, consoles).
7. A pointer to the environment strings.
8. A pointer to the name of the new process' current working directory.
9. A pointer to a structure describing the initial window on the screen.
10. A pointer to a structure that returns 18 values to the called.
Windows 7 does not enforce any kind of parent-child or other hierarchy. All
processes are created equal. However, since 1 of the 18 parameters returned to the
creating process is a handle to the new process (allowing considerable control over
the new process), there is an implicit hierarchy in terms of who has a handle to
whom. Although these handles cannot just be passed directly to other processes,
there is a way for a process to make a handle suitable for another process and then
give it the handle, so the implicit process hierarchy may not last long.
Each process in Windows 7 is created with a single thread, but a process can
create more threads later on. Thread creation is simpler than process creation: Cre-
ateThread has only six parameters instead of 10: the security descriptor, the stack
size, the starting address, a user-defined parameter, the initial state of the thread
(ready or blocked), and the thread's ID. The kernel does the thread creation, so it
is clearly aware of threads (i.e., they are not implemented purely in user space as is
the case in some other systems).
When the kernel does scheduling, it looks only at the runnable threads and
pays no any attention at all to which process each one is in. This means that the
kernel is always aware of which threads are ready and which ones are blocked.
Because threads are kernel objects, they have security descriptors and handles.
Since a handle for a thread can be passed to another process, it is possible to have
Search WWH ::




Custom Search