1 / 139

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

ecs150 Spring 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.

rowa
Download Presentation

ecs150 Spring 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 Spring 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 Spring 2006

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

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

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

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

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

  7. ecs150 Spring 2006

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

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

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

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

  12. About the Instructor • S. Felix Wu • sfelixwu@gmail.com, x4-7070 • Office: 3057 Engineering II • Office Hours: • 1-2 p.m. on Tuesday and Friday • by appointment ecs150 Spring 2006

  13. About the TA • TA Valerie Szudziejka (szudziej@cs.ucdavis.edu) • Office Hours: TBA • Discussion: ecs150 Spring 2006

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

  15. Textbook Reading this book itself is 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 Spring 2006

  16. 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 Spring 2006

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

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

  19. 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 Spring 2006

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

  21. Course Requirements • 48%: Programming Assignments • teamwork: 1~3 students • 3 Programming Assignments (12%, 18%, 18%) • 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 three sessions. ecs150 Spring 2006

  22. Grading • I will give +/- grades. • possible grading (not finalized): • A: >= 93 A-: >= 90 B+: >= 87 • B: >= 84 B-: >= 81 C+: >= 78 • C: >= 75 C-: >= 72 D : > 60 ecs150 Spring 2006

  23. FreeBSD • Your team need to have access to a FreeBSD environment • I386, VMware, VirtualPC ecs150 Spring 2006

  24. The Structure of OS • The Kernel • Processes and Threads • The System Call Interface ecs150 Spring 2006

  25. What is “kernel”? ecs150 Spring 2006

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

  27. ….what are the basic services? OS ecs150 Spring 2006

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

  29. ecs150 Spring 2006

  30. 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 Spring 2006

  31. Kernel & Processes • The concept of “application process” ecs150 Spring 2006

  32. 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 Spring 2006

  33. 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 Spring 2006

  34. ecs150 Spring 2006

  35. ecs150 Spring 2006

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

  37. 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 Spring 2006

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

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

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

  41. 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 Spring 2006

  42. System Entry Vector fork() Trap : : ecs150 Spring 2006

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

  44. kldload fork() Trap XYZ() : : ecs150 Spring 2006

  45. Process • Process – a program in execution • A process includes: • program counter • stack • data section ecs150 Spring 2006

  46. Context Switching ecs150 Spring 2006

  47. Running Running Running Running Blocked Blocked Blocked Blocked Ready Ready Ready Ready Scheduling & Context Switching ecs150 Spring 2006

  48. Running Waiting Ready States of a Process • Running, Blocked, and Ready ecs150 Spring 2006

  49. ecs150 Spring 2006

  50. 1 RR 0 0 : : . 256 different priorities 64 scheduling classes 0~63 bottom-half kernel (interrupt) 64~127 top-half kernel 128~159 real-time user 160~223 timeshare 224~255 idle 1 0 1 ecs150 Spring 2006

More Related