Operating Systems 2017F Lecture 17
Midterm Review
6. uses of signals: - kill process - find out when child process is terminated - start/stop a process - detect when a program has made a ptr error
7. Pointers in C contain virtual memory addresses because the memory of a process is a virtual address space. Each process thinks it has its own stretch of memory.
8. processes make a sys call to allocate memory. execve -> then mmap and/or sbreak to allocate memory
9. shell opens the file output.txt.
10. mmap contents of file can allocate the contents of it into ram. - comparing 1 mb of both files at a time will be less expensive - only makes sense to mmap if you will access files multiple times
11. producer and consumer now have no way of talking to each other because they do not share the same memory.
12. no. there is a race condition. while loop loops while sem < 0. someone else could access and modify the variable between the while and the sem--;. - you need special instructions to test and set the variable at the same time. - also, sem isn't a ptr so it's a local variable.
Additional Notes
How do you do kernel hacking? Some tips for low level kernel code:
--Be humble; You cannot know how everything works
Verify your assumptions as you go
--Perform lots of experiments
--Incremental Development, compile and run often