1 / 149

ecs150 Fall 2007 : Operating System #1: OS Architecture, Kernel, & Process

ecs150 Fall 2007 : Operating System #1: OS Architecture, Kernel, & Process. Dr. S. Felix Wu Computer Science Department University of California, Davis http://www.cs.ucdavis.edu/~wu/ sfelixwu@gmail.com.

noelle
Download Presentation

ecs150 Fall 2007 : Operating System #1: OS Architecture, Kernel, & Process

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. ecs150 Fall 2007:Operating System#1: OS Architecture, Kernel, & Process Dr. S. Felix Wu Computer Science Department University of California, Davis http://www.cs.ucdavis.edu/~wu/ sfelixwu@gmail.com ecs150 Fall 2007

  2. VM/MVS, DOS, Win95/98/ME/2000/XP, Freebsd/Linux, MacOS-10, Mach, Minix, PalmOS, uCOS, TinyOS, … ecs150 Fall 2007

  3. ….where applications meet Hardware!!! Applications…….. OS Hardware: CPU/Memory/HD/DVD/Wireless… ecs150 Fall 2007

  4. “Information Router” • One NIC a process’s user-level memory • One file another file • OS kernel layer • Hardware layer ecs150 Fall 2007

  5. ….where applications meet Hardware!!! Applications…….. OS Hardware: CPU/Memory/HD/DVD/Wireless… ecs150 Fall 2007

  6. This quarter…. • The internals of OS • The basic design principles of OS • The skills to modify or implement an OS. ecs150 Fall 2007

  7. Operating System • An interesting balance between: • Theories and Practical Experiences/Experiments • Architectural Concept and Detailed Design • Formal Verification and Empirical Validation ecs150 Fall 2007

  8. About the Instructor • S. Felix Wu • sfelixwu@gmail.com • Facebook group (under UCD network): ecs150 • Office: 3057 Engineering II • Phone: 530-754-7070 • Office Hours: • 1-2 p.m. on Tuesday and Friday • by appointment ecs150 Fall 2007

  9. ecs150 Fall 2007

  10. Why 3 email addresses? • sfelixwu@gmail.com • sfwu@ucdavis.edu • sfelixwu@yahoo.com ecs150 Fall 2007

  11. Why 3 email addresses? • sfelixwu@gmail.com • sfwu@ucdavis.edu • My main email contact for everything all the time. • sfelixwu@yahoo.com ecs150 Fall 2007

  12. Why 3 email addresses? • sfelixwu@gmail.com • sfwu@ucdavis.edu • My main email contact for everything all the time. • sfelixwu@yahoo.com • Read only once in the past three months… ecs150 Fall 2007

  13. Why 3 email addresses? • sfelixwu@gmail.com read/response during the quarters, especially before the homework deadlines. • sfwu@ucdavis.edu • My main email contact for everything all the time. • sfelixwu@yahoo.com • Read only once in the past three months… ecs150 Fall 2007

  14. Anti-Spam •  sfelixwu@gmail.com •  subject: [ecs150 f2007]… • [ecs150 2007]is the cyber social link between the instructor and the students in ecs150, fall 2007. ecs150 Fall 2007

  15. Anti-Spam •  sfelixwu@gmail.com •  subject: [ecs150 f2007]… • [ecs150 f2007] is the cyber social link between the instructor and the students in ecs150, fall 2007. • Let’s see by the end of quarter whether this little secret will be known to the spammers… ecs150 Fall 2007

  16. About the TA • TA Sean Whalen (shwhalen@gmail.com) • Office Hours: TBA • Discussion: Mon 4:10~5:00 (146 Olson) ecs150 Fall 2007

  17. about Web site • http://www.cs.ucdavis.edu/~wu/ecs150/ • Also the Facebook group • all lectures, notes, announcements, homework assignments, tools, papers will be there. ecs150 Fall 2007

  18. Textbook Reading this book itself may be a major challenge. But, you really learn when you go through this process! "The Design and Implementation of the FreeBSD Operating Systems" by Marshall Kirk McKusick and George V. Neville-NeilAddison Wesley Professional, 2005, ISBN 0-201-70245-2. http://www.freebsd.org/ ecs150 Fall 2007

  19. Prerequisites • Programming Languages: C and assembly (ecs50) • Date Structure (ecs110) and basic Computer Architecture (ecs154a/eec70). • ecs40 • Please talk to me if you have any concern. ecs150 Fall 2007

  20. Syllabus • Process/Kernel (09) • Memory Management (06) • Midterm (11/01/2007, in class) • IO & File Systems (10) • Others (03) • Final (12/13/2007, 8~10 a.m.) ecs150 Fall 2007

  21. OS Principles/Concepts • What is “kernel”? • What is the difference between a process and a thread? • What is the difference between user-level and kernel-level threads? • What is the difference between a system call and a library function call? • What are SJF, RR, Lottery, LRU, TLB, Second Chance? • How to do Mutual Exclusion? • What is the difference between deadlock prevention and avoidance? • What are the differences among hardware interrupt, hardware trap, and software trap? ecs150 Fall 2007

  22. OS • Let’s examine OS concepts in a realistic context: “FreeBSD” • Then, we can re-think those concepts…. • And, maybe you will realize later that some of the concepts are either “misleading” or “irrelevant” in certain context. ecs150 Fall 2007

  23. Principles vs. Practice • Ideas and Theories first, then we will go over some FreeBSD code segments. • You will need to learn FreeBSD internals for programming assignments!! • The first few discussion sessions will be dedicated to FreeBSD internals. • Most of the discussion sessions are very important and they will appear in the exams and homeworks. ecs150 Fall 2007

  24. Course Requirements • 48%: Programming Assignments • teamwork: 1~2 students (no more than 2!) • 4 Assignments (10%, 18%, 12%, 8%) • HW#1 is out. • 16%: In-class open-book midterm • 32%: open-book final • 04%: Participation of Lectures and Discussion sessions. • Deducted if missed more than TWO sessions. ecs150 Fall 2007

  25. Grading • I will give +/- grades. • possible grading : • A: >= 92 A-: >= 89 B+: >= 85 • B: >= 82 B-: >= 79 C+: >= 75 • C: >= 72 C-: >= 69 D+: >= 65 • D: >= 62 D-: >= 59 ecs150 Fall 2007

  26. FreeBSD • You need to have access to a FreeBSD environment • I386, QEMU, VMware, VirtualPC, Parallel ecs150 Fall 2007

  27. virtualization Unmodified Applications Unmodified OS (XP, Linux, Solaris, or, FreeBSD) Standard Full Virtualization  e.g., VirtualPC WindowXP Hardware ecs150 Fall 2007

  28. ecs150 Fall 2007

  29. FreeBSD Unmodified Applications Unmodified OS (XP, Linux, Solaris, or, FreeBSD) API Virtual PC or VMware Hardware ecs150 Fall 2007

  30. Programmable Virtualization Unmodified Applications Unmodified OS (XP, Linux, Solaris, or, FreeBSD) “Programmable” Full Virtualization API DLVM DLVM Hardware ecs150 Fall 2007

  31. The Structure of OS • The Kernel • Processes and Threads • The System Call Interface ecs150 Fall 2007

  32. What is “kernel”? ecs150 Fall 2007

  33. Kernel • The basic OS services • Which services? What is it doing? • Let’s check a couple examples ecs150 Fall 2007

  34. ….what are the basic services? OS ecs150 Fall 2007

  35. FreeBSD Kernel: Services • Timer/clock, descriptor, process • Memory Management: paging/swapping • I/O control and terminal • File System • Inter-process communication • Networking ecs150 Fall 2007

  36. ecs150 Fall 2007

  37. Kernel of SVR2 of AT&T Unix User programs Libraries user trap System Call Interface File subsys Process Control Subsys. Inter-Process Communication Buffer cache kernel Scheduler Character block device drivers Memory Management Hardware Control hardware ecs150 Fall 2007

  38. Kernel & Processes • The concept of “application process” ecs150 Fall 2007

  39. Kernel and User Space Memory space for this process Process FOO program System call (or trap into the kernel) conceptually Process FOO in the Kernel System Call Kernel Resources (disk or IO devices) ecs150 Fall 2007

  40. Processes > ps PID TTY TIME CMD 2910 pts/4 0:00 tcsh > ps -ef UID PID PPID C STIME TTY TIME CMD root 0 0 0 Sep 25 ? 0:01 sched root 1 0 0 Sep 25 ? 0:00 /etc/init - root 2 0 0 Sep 25 ? 0:00 pageout root 3 0 0 Sep 25 ? 0:01 fsflush root 223 1 0 Sep 25 ? 0:00 /usr/lib/utmpd root 179 1 0 Sep 25 ? 0:00 /usr/sbin/cron root 273 1 0 Sep 25 ? 0:00 /usr/lib/saf/sac -t 300 root 56 1 0 Sep 25 ? 0:00 /usr/lib/devfsadm/devfseventd root 58 1 0 Sep 25 ? 0:00 /usr/lib/devfsadm/devfsadmd root 106 1 0 Sep 25 ? 0:00 /usr/sbin/rpcbind root 197 1 0 Sep 25 ? 0:01 /usr/sbin/nscd root 108 1 0 Sep 25 ? 0:00 /usr/sbin/keyserv root 168 1 0 Sep 25 ? 0:00 /usr/sbin/syslogd root 118 1 0 Sep 25 ? 0:00 /usr/lib/netsvc/yp/ypbind root 159 1 0 Sep 25 ? 0:00 /usr/lib/autofs/automountd ecs150 Fall 2007

  41. ecs150 Fall 2007

  42. ecs150 Fall 2007

  43. Memory Structure heap High Arguments String Growth Return address library Prev. frame pointer stack Local variables Stack Pointer Stack Growth Low ecs150 Fall 2007

  44. Memory Structure heap High foo Arguments String Growth bar( ) {……} foo( ) { …… call bar( ); …… } Return address bar Prev. frame pointer Local variables Stack Pointer Stack Growth Low ecs150 Fall 2007

  45. Procedure Call on the sameUser Stack Per-process Kernel Stack User-stack Disk Heap Initialized data Initialized data text text a.out header Memory a.out magic number ecs150 Fall 2007

  46. System Call on a different stack Per-process Kernel Stack User-stack Disk Heap Initialized data Initialized data text text a.out header Memory a.out magic number ecs150 Fall 2007

  47. System Calls • Not a “normal” procedure call • It is a software trap “into” the kernel • Hardware interrupt • Hardware trap • Software trap ecs150 Fall 2007

  48. System Entry • Hardware interrupt • Asynchronous, might not relate to the context of the executing process • Hardware trap • Related to the current executing process, e.g., divided by zero • Software-initiated trap • Instructions, int ecs150 Fall 2007

  49. System Entry Vector fork() Trap : : ecs150 Fall 2007

  50. System Entry Vector fork() Trap Reserved for loadable system calls : : XYZ() ecs150 Fall 2007

More Related