-
Write a one-line C (or C++) program using Win32 that shuts down a single
executing Notepad process (if one exists). All you need to use are the
Win32 functions FindWindow and PostMessage. The window class for the
Notepad application is "Notepad".
-
Write two little Windows programs that illustrate how kernel objects can
be used for interprocess synchronization. The first program should
create an event object with a name. The second program should open that
event then wait on it (right after displaying a message that it is going
to wait :-). A button in the first program can be pressed to pulse the
event, which will release the waiting thread in the second process.
The second process should display a message that it was released.
You don't need any fancy graphics here, but you must be sure to clean
up handles, etc.
-
Normally one uses low-level constructs such as mutexes, semaphores and
events to build higher-level constructs such as monitors. The reverse
is possible. Make an AutoResetEvent class in Java, which functions like
a Windows API AutoReset Event. You'll need set(), reset() and pulse()
members to correspond to Windows API SetEvent(), ResetEvent() and PulseEvent()
APIs. Implement the functionality of CreateEvent in the constructor.
You do not need to emulate OpenEvent(), nor do you need to make the
event object usable in multiple processes at the same time. Note that
you'll need a method to wait on the event, since Java has no real
equivalent to WaitOnSingleObject().
-
In my Windows DiningPhilosophers program, could I have used Critical
Section objects in place of Mutexes? Why or why not?
-
Write a Windows application which creates a thread with priority level 31
that busy waits for 30 seconds. Run it and explain what happened.
-
Write a multithreaded Java server running at port 9850
which accepts a string from the user that represents a non-negative
integer (call it n) and sends back the first n decimal digits
of pi. If the number submitted is very large, the generation
and transmission of the reply could take an enormously long
time. Therefore set a time limit of 30 seconds on the amount
of work for any request: if the server isn't done generating
n digits in 30 seconds, just stop sending. Use whatever
kind of Timer object or scheduled service you like. Use
a thread pool for the server rather than spawning a new thread
for each request.