Question: [ Process Creation and System Calls ] Different OS will have different system calls/APIs which offer different functionality for the basic task of creating new
[ Process Creation and System Calls ]
Different OS will have different system calls/APIs which offer different functionality for the basic task of creating new processes (or threads but you can ignore threads for this question) and the running of executables. In Windows, the basic process creation API is CreateProcess. It is an API rather than a system call because Windows can be thought of as a kind of micro-kernel architecture (see [TAN] 1.7.3 if you want to know more about micro-kernel and [TAN] 11.4.2 for more on Windows CreateProcess). There are two versions of CreateProcess (one for Ansi characters and the other for Unicode characte3rs), for our purposes we will not distinguish them, and will just use CreateProcessA (Ansi version). (If you do not understanding about encodings, just think of it as APIs which deal with ASCII single byte strings or multi-byte strings which include other languages which cannot fit within one byte, e.g. Chinese, Japanese, Greek, etc.).
(a) I mentioned that Windows API is much more complex than Unix. To avoid getting bogged down in other complexities of Windows, for this question, we will only compare the following parameters:
LPCSTR lpApplicationName, LPSTR lpCommandLine, LPVOID lpEnvironment
Suppose we have a simplified CreateProcess API with only: CreateProcessSimple(lpApplicationName, lpCommandLine, lpEnvironment). Sketch using pseudocode (or C code) how to implement Windows code using CreateProcessSimple with Unix APIs (fork and exec family). Note: just a sketch is sufficient as this question is meant to contrast Windows with Unix rather than to implement real code.
(b) Discuss why the Unix APIs/system calls are simpler than the single Windows CreateProcess API (the full CreateProcessA and not CreateProcessSimple). Use lpCurrentDirectory in CreateProcess as an example of features embedded in the Windows CreateProcess API. Would Unix need to enhance the system calls in a similar way to deal with the current directory?
Hints: For (a), look at the Windows page on CreateProcess and you can omit the details which are not considering. Contrast with the relevant Unix ones. For (b), in Unix, the system call to set the working directory is chdir
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
