Operating Systems 2017F Lecture 17: Difference between revisions

From Soma-notes
Rquaium (talk | contribs)
Rquaium (talk | contribs)
Line 40: Line 40:
<br>  
<br>  
Realize that the assumptions behind code you don't necessarily match to your own<br>
Realize that the assumptions behind code you don't necessarily match to your own<br>
Understand the "flow of control" inside the program
Understand the "flow of control" inside the program<br>
*Architecture<br>
*Division of responsibilities<br>
*Purpose of data structures/objects<br>

Revision as of 18:41, 14 November 2017

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

Check for errors ALWAYS
This will save you from later errors
Kernel has to live cleanly

Find another part of the kernel that is close to what you want to do (Search online! This is a good link: http://elixir.free-electrons.com/linux/v4.4.83/source)http://elixir.free-electrons.com/linux/v4.4.83/source)
You do not understand all abstractions and assumptions, so "pattern match" to minimize trouble

Realize that the assumptions behind code you don't necessarily match to your own
Understand the "flow of control" inside the program

  • Architecture
  • Division of responsibilities
  • Purpose of data structures/objects