1 / 42

Discussion Week 4

Discussion Week 4. TA: Kyle Dewey. Overview. Project #1 debriefing System calls Project #2. Task 1 Bugs/Ugliness. About that Project. I’m not actually grading anything (probably) Clarity is a wonderful thing I apologize for any incorrect information

arnaud
Download Presentation

Discussion Week 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Discussion Week 4 • TA: Kyle Dewey

  2. Overview • Project #1 debriefing • System calls • Project #2

  3. Task 1 Bugs/Ugliness

  4. About that Project... • I’m not actually grading anything (probably) • Clarity is a wonderful thing • I apologize for any incorrect information • Output is not the same with semaphores • Please output information in laundromat

  5. System Calls

  6. Why Operating Systems? • Multitasking • Resource management • CPU • Memory • Disks • Printers...

  7. Abstraction • “I just want to print!” • Lots of different, very similar hardware • Unify with a common interface

  8. Isolation • Each process “thinks” it is the only one on the system • Each has access to resources

  9. Total Resource Access • Process A prints “Hello world!” • Process B prints “Goodbye cruel world!” Hello woGoodbye crld! ruel world!

  10. Mediated Access • Gain access through another entity • The entity makes sure everything is isolated

  11. Mediated Access • Process A prints “Hello world!” • Process B prints “Goodbye cruel world!” Hello world! Goodbye cruel world!

  12. “Entity” • The entity is the OS • The pathway for mediation is a system call • System calls allow processes to communicate with the OS

  13. Syscall Frequency • Any I/O (network, disk, ...) • Any process manipulation • Interprocess communication • Shared library access • Essentially access to any shared resource

  14. Tools • strace: Linux tool for intercepting syscalls • truss: Solaris/BSD tool for intercepting syscalls • Usage: strace ./a.out

  15. “Useless” C Program

  16. C Hello World

  17. Java Hello World (Note -F -f was needed)

  18. Python Hello World

  19. The Point • Syscalls are made all over the place • Rarely, if ever, directly called in actual code • Unwieldy • Layer of abstraction

  20. System Call Execution read() read() User Space read() readFromDisk() Kernel Space

  21. Why Kernel Space? • Kernel executes call “on behalf” of a process • If a normal process could do it, then there is no isolation • Possible to have more than just “kernel level” and “user level”

  22. Something in Between - Microkernels • Goal: put as much of the kernel as possible in user space • Turns out a lot can be done in user space

  23. Microkernel

  24. Project #2 Part 1

  25. Basic Idea • Implement system calls for basic process and file manipulation • Note that “basic” means the base of everything - not simple!

  26. Syscall Naming in NACHOS • Names shared with threads implementation • These are very different, though you may need the corresponding thread operations

  27. Fork( func ) • Copies address space of caller • Creates a new process in this copied address space • Executes the given function, with this new process in the new address space • Note the dissimilarity to UNIX’s fork()

  28. Fork() Example

  29. Yield() • Temporary yields the calling process to any other processes available to run

  30. Exit( int ) • Terminates the calling thread • The parameter is the exit status (ignored for this project)

  31. Exec( filename ) • Spawns a new process • Executes the code specified in filename using the new process • Note this does not clobber the calling process, as it does with UNIX

  32. Join( SpaceId ) • Waits for the process with the given SpaceId • The calling process blocks until the process backing SpaceId returns

  33. Project #2 Part 2

  34. NACHOS Filesystem • Under Linux, it’s simply a single big file • Under NACHOS, it contains NACHOS’ directory hierarchy • Unless otherwise mentioned, the slides refer to the NACHOS hierarchy

  35. UNIX Similarity • NACHOS is modeled after UNIX • Some files are actually device interfaces

  36. Filesystem Stubs • Some stubs are provided that may help • Extremely basic and limited • May need to scrap entirely

  37. Create( name ) • Create a new, empty file with the given name • Note that you need to be able to extend file lengths - FileSystem::Create indicates an issue with this

  38. Open( name ) • Opens the file with the given name • Returns NULL if it does not exist

  39. Close( OpenFileId ) • Closes the file denoted by the given open file ID

  40. ReadAt( buffer, size, pos ) • Reads size bytes starting at pos into buffer • Note that this is a method on the OpenFile object

  41. WriteAt( buffer, size, pos ) • Write size bytes from buffer, starting at pos • Note that this is a method on the OpenFile object

  42. Project #2 Notes • Far more provided detail • Well-defined outputs • Due November 8 at midnight • Much more difficult than project #1 (worth twice as much, too)

More Related