1 / 151

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

ecs150 Fall 2006 : 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.

Download Presentation

ecs150 Fall 2006 : 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 2006: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 2006

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

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

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

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

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

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

  8. About the Instructor • S. Felix Wu • sfelixwu@gmail.com • sfwu@ucdavis.edu • sfelixwu@yahoo.com • Office: 3057 Engineering II • Phone: 530-754-7070 • Office Hours: • 1-2 p.m. on Tuesday and Friday • by appointment ecs150 Fall 2006

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

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

  11. 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 2006

  12. 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 2006

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

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

  15. About the TA • TA Daniel Wu (danwu@ucdavis.edu) • Office Hours: TBA • Discussion: Monday ecs150 Fall 2006

  16. about Web site • http://www.cs.ucdavis.edu/~wu/ecs150/ • all lectures, notes, announcements, homework assignments, tools, papers will be there. ecs150 Fall 2006

  17. 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 2006

  18. 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 2006

  19. Syllabus • Process/Kernel (09) • Memory Management (06) • midterm • IO & File Systems (10) • Others (03) • final ecs150 Fall 2006

  20. 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 2006

  21. 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 2006

  22. 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 2006

  23. Course Requirements • 48%: Programming Assignments • teamwork: 1~2 students (no more than 2!) • 4 Assignments (10%, 18%, 12%, 8%) • HW#1 is out (check the website). • 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 2006

  24. 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 2006

  25. FreeBSD • You need to have access to a FreeBSD environment • I386, QEMU, VMware, VirtualPC ecs150 Fall 2006

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

  27. ecs150 Fall 2006

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

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

  30. The Structure of OS • The Kernel • Processes and Threads • The System Call Interface ecs150 Fall 2006

  31. What is “kernel”? ecs150 Fall 2006

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

  33. ….what are the basic services? OS ecs150 Fall 2006

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

  35. ecs150 Fall 2006

  36. 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 2006

  37. Kernel & Processes • The concept of “application process” ecs150 Fall 2006

  38. 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 2006

  39. 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 2006

  40. ecs150 Fall 2006

  41. ecs150 Fall 2006

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

  43. 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 2006

  44. 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 2006

  45. 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 2006

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

  47. 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 2006

  48. System Entry Vector fork() Trap : : ecs150 Fall 2006

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

  50. kldload fork() Trap XYZ() : : ecs150 Fall 2006

More Related