蛮郁闷!老师给我们布置的编程题都是用E文,题目都难看不懂,哪能展拳脚啊!借大家的优势一用!高分相送!
Experiment 1
The usage of some Win32 APIs performing the system call function.
–Create a new process.
–Create another process that waits for the preceding process to exit and then exits itself.
–Be familiar with the usage of other Win32 APIs through reading relevant comments and examples in MSDN.
=============
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) ); // Start the child process.
if( !CreateProcess("D:\\Winamp\\Winamp.exe", // Module name.
NULL, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
::MessageBox( NULL,"CreateProcess failed." ,"CreateProcess failed.",MB_OKCANCEL);
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
==========================================
Experiment 2
Solve the producer-consumer problem using semaphore.
–Create semaphore.
–Manipulate semaphore.
–Create threads.
–Coordinate the execution of multiple threads.
–Program a simulation implementing the producer-consumer problem.
CreateThread
CreateSemaphore
WaitForSingleObject
ReleaseSemaphore
ExitThread
SetThreadPriority
Several Candidate Win32 APIs
=========================================
Experiment 3
Program a simulation of the banker’s algorithm. Your program should cycle through each of the bank clients asking for a request and evaluating whether it is safe or unsafe. Output a log of requests and decisions to a file.
–Each client can be modeled by an array of resource requests.
–At each scheduling point, a request chosen randomly is evaluated ( The lottery heduling algorithm seems to be a good candidate).
–Record a log into an array and output it finally.
=========================================
Experiment 4
Write a program that simulates a paging system. At the start of the program, the user should be asked to choose a page replacement algorithm, e.g. FIFO, LRU.
–Input the numbers of referenced pages.
–Generate a list similar to Fig.4-25.
–Compare the performance of different page replacement algorithms, e.g. page fault rate.
========================================
Experiment 5
The usage of Win32 APIs relevant to file operations.
–Create a file.
–Read and write a file.
–Copy and delete a file.
–Directory operations.

