1 / 27

Operating Systems

Operating Systems. Recitation 1. Contact details. TA: Aviad Zuck aviadzuc@tau.ac.il Office hours: Thursday 17:10-18:00, Schreiber 012 Course homepage: available from cs.tau.ac.il /~ aviadzuc /OS2014a.htm All homework and presentations are there. Assignments.

jin
Télécharger la présentation

Operating Systems

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. Operating Systems Recitation 1

  2. Contact details • TA: AviadZuck • aviadzuc@tau.ac.il • Office hours: Thursday 17:10-18:00, Schreiber 012 • Course homepage: available fromcs.tau.ac.il/~aviadzuc/OS2014a.htm • All homework and presentations are there

  3. Assignments • All homework assignments must be performed individually. • We are serious about this! • CHEATING == COPYING == FAILING! • No “official” grades • Pass/fail • Not submitting==poor submission==failing • “Grades” & best solutions published on website • One simple homework assignment ~ class • Usually practice of APIs taught in class

  4. Submission guidelines • Submission to bodek by e-mail • cs.itai.katz@gmail.com • 2 Weeks for submitting • All mandatory • 1 is not. 3 late submissions allowed (1 week each) • We are serious about this too • No need to notify anyone when submitting late/skipping submission • Carefully read detailed guidelines on the course’s Web page • If you did not submit on time, did not provide a miluim or medical note, and are out of late submissions, and have skipped submitting more than one assignment you will not pass the course. Even for one assignment.

  5. Classes Each class generally consists of 2 parts: • Part I: Review of general OS concept and its Unix implementation & APIs • Part II: “On-projector” development/coding of an application which makes use of the presented concept

  6. Not necessarily in order of class lectures! • Will try uploading presentation before class • But changes are made in last minute, “final” slides only in class!

  7. Unix Development • University/home – • Any command line editor (vim, pico, emacs, gedit…) • No makefile required! • Home – • PC with Windows XP/vista/7/8 +cygwin/VM or popular distribution (Ubuntu, Debian) • All of the above editors • Useful IDE – eclipse. Download free http://www.eclipse.org/downloads/ • Eclipse == OVERKILL! NO LINKAGE, most assignments in single c file without header • From command line: gcc hw1.c –o hw • Resources (besides website) • Everything at www.google.com. Really!

  8. Some more useful resources • Sivan Toledo book on Operating Systems (בעברית) • On course website • http://linux.die.net – Linux documentation, All man pages, various guides and more • http://msdn.microsoft.com/ - same for Windows • http://www.trembath.co.za/commands2.html - useful summary of command line utilities • http://beej.us/guide/bgnet/ - illustrative guide to network programming • http://lwn.net/Kernel/LDD3/ - book (pdf) on linux device drivers and kernel internals

  9. Using virtual machine • Some assignments will require using a virtual machine with Linux • We’ll see how to do that next week • Will use Virtualbox with Xubuntu (available on website) • Easy and useful

  10. Administration • HW #1 – on site later

  11. Plan • System calls • Intro • File-related • Managing data storage as example for importance of OS

  12. System Calls • A service the operating system (OS) provides to applications • Kernel sensitive operations - hardware access (IO), special privileges… • Lets google it • We’ll explain later in the course how they really work

  13. Command Shell Processor • “Terminal” in Ubuntu (university) • tcsh, csh, bash • In-class examples and assignments will be Unix console applications

  14. Useful console commands • ls, grep, top, cat, head, tail, echo, less • Link to detailed list on website • man (very useful!) • man 2 mostly system calls • man open

  15. OS core is the Kernel • OS Kernel manages internal data structures for users • To really get the most out of it, sometimes need to know what goes on “under the hood” • How? taking operating systems course helps (sometimes)

  16. Today’s agenda: Unix files • Return/manipulate internal kernel handle • creat() • read() • write() • close() • Win32 specific – on msdn (very similar in THIS case)

  17. open()/close() int open(const char *pathname, int flags, mode_t mode) int close(intfd) • Open file, return “file descriptor” == internal handle • Handle == offset in kernel data structure… • path – path to new file (“/home/aviadzuc/newfile.txt”) • flags – access modes • O_RDONLY, O_WRONLY, O_RDWR • O_CREAT – create file (if doesnt exist) • mode – file permissions. • Restrict access of others to files • Not obligatory, except when? • Return -1 on failure, valid positive number on success • Close() - deletes handle

  18. creat() intcreat(const char *path, mode_t mode) • Create new file • What does man page say?

  19. read() ssize_t read(intfd, void* buf, size_t count) • Read data from file • fd – file descriptor (internal handle) of open()ed file • buf – buffer to read data into • count – how many bytes to read • Return number of bytes written, -1 on error • What do we get on subsequent calls to read()?

  20. write() ssize_t write(intfd, void* buf, size_t count) • Write data to file • fd – file descriptor (internal handle) of open()ed file • buf – buffer to read data into • count – how many bytes to write • Return number of bytes written, -1 on error • Subsequent calls?

  21. stat() int stat(const char *path, struct stat *buf) • Retrieve file information • path – path to file • buf – struct with relevant fields (see man 2 page • Return 0 on success, -1 on error

  22. Storage hierarchy • Disks faster on sequential accesses due to mechanical reasons • Disk is not “byte-addressable”, only accessed in units called blocks/sectors - 0.5KB (or multiples such as 2KB,4KB, …) • What are the implications for storage management in the OS?

  23. Size does matter • Storage mainly on slow magnetic disks • Result - need to optimize! • Operating system (OS) uses (fast) main memory to buffer accesses to (slow) disk

  24. Access pattern as well • OS tries to write/read in large sequential chunks

  25. Alignment too • OS fits accesses to Disk properties • Need to avoid • small accesses • Unaligned accesses

  26. Directories • Containers of files • today just look at code with relevant system calls • Will explain some more next week • What you need to know - basically files too, accessed with special handles…

  27. Let’s do some programming • Use console window: • Open and read first 10 characters of a file • Make system calls to fetch list of the files in current directory • Print out results

More Related