Home > Articles > Operating Systems, Server > Microsoft Servers

  • Print
  • + Share This
This chapter is from the book

Exercises

6–1.

Extend Program 6-1 (grepMP) so that it accepts command line options and not just the pattern.

6–2.

Rather than pass the temporary file name to the child process in Program 6-1, convert the inheritable file handle to a DWORD (a HANDLE requires 4 bytes) and then to a character string. Pass this string to the child process on the command line. The child process, in turn, must convert the character string back to a handle value to use for output. The catHA.c and grepHA.c programs on the book's Web site illustrate this technique.

6–3.

Program 6-1 waits for all processes to complete before listing the results. It is impossible to determine the order in which the processes actually complete within the current program. Modify the program so that it can also determine the termination order. Hint: Modify the call to WaitForMultipleObjects so that it returns after each individual process terminates. An alternative would be to sort by the process termination times.

6–4.

The temporary files in Program 6-1 must be deleted explicitly. Can you use FILE_FLAG_DELETE_ON_CLOSE when creating the temporary files so that deletion is not required?

6–5.

Determine any grepMP performance advantages (compared with sequential execution) when you have an SMP system or when the files are on separate or network drives. Appendix C presents some partial results.

6–6.

Can you find a way, perhaps using job objects, to collect the user and kernel time required by grepMP? It may be necessary to modify grepMP to use job objects.

6–7.

Enhance the DisplayJobs function (Program 6-5) so that it reports the exit code of any completed job. Also, give the times (elapsed, kernel, and user) used so far by all jobs.

6–8.

The job management functions have a defect that is difficult to fix. Suppose that a job is killed and the executive reuses its process ID before the process ID is removed from the job management file. There could be an OpenProcess on the process ID that now refers to a totally different process. The fix requires creating a helper process that holds duplicated handles for every created process so that the ID will not be reused. Another technique would be to include the process start time in the job management file. This time should be the same as the process start time of the process obtained from the process ID. Note: Process IDs will be reused quickly. UNIX, however, increments a counter to get a new process ID, and IDs will repeat only after the 32-bit counter wraps around. Therefore, Windows programs cannot assume that IDs will not, for all practical purposes, be reused.

6–9.

Modify JobShell so that job information is maintained in the registry rather than in a temporary file.

6–10.

Extend JobShell so that the processes are associated with a job object. Impose time and other limits on the jobs, allowing the user to enter some of these limits.

6–11.

Enhance JobShell so that the jobs command will include a count of the number of handles that each job is using. Hint: Use GetProcessHandleCount, which requires NT 5.1.

6–12.

Build project Version (on the Web site), which uses version.c. Run the program on as many different Windows versions as you can access, including Windows 9x and NT 4.0 systems if possible. What are the major and minor version numbers for those systems, and what other information is available?

  • + Share This
  • 🔖 Save To Your Account