Assume the usual general instructions!
http://homepage.cs.uiowa.edu/~dwjones/opsys/threads/Note! A small update has been made to the package that may allow it to run correctly under MS Visual C and C++. These changes don't relate to this assignment, but if you've been playing with this thread package, they may help.
Assume we've modified the thread package so that it uses the programmable interval timer to support preemptive context switching between threads.
Note that the timer sends a signal to the application process that forces premature termination of I/O operations. Before you started using preemptive threads, your code worked correctly with things like write(1,"string\n",7) to output the line "string" to stdout. After you started using preemption, this would occasionally output just "stri" or even "s".
Part A: Rewrite your application code that said write(1,"string\n",7) to operate correctly under the preemptive thread manager (some relevant material is in the notes for lecture 14, but you'll also find help in the UNIX man page for write).
Part B: Package your solution to part A in a function, thread_write, that can be substituted for all calls to write in your program.
a) We could add a system call "anticipate(x)" that the user can use to predict that a use of page x will come soon, and then urge users to include it in their code whenever they can guess future reference patterns of their program.
b) We could ask the system to attempt to anticipate user reference patterns. For example, when a page fault occurs for page x, the system could check to see if page x+1 is in memory, and if it is not, schedule a read for that page too, since most memory references tend to be sequential.