410 likes | 588 Views
CSE 331 OPERATING SYSTEM DESIGN Spring 2012-13 Prof. Dr.Sebnem Baydere TA: Kemal Serdaroğlu Lectures: Mon: 11:00-12:50, Tue:11:00-11:50 Labs: Wed 14:00-16:00, Thu: 16:00-18:00 Prerequisites :CSE 211, CSE 232 CSE 323 (strongly recommended). Course Mechanics. GRADING & EXAMS Final: 30%,
E N D
CSE 331 OPERATING SYSTEM DESIGN Spring 2012-13 Prof. Dr.Sebnem Baydere TA: Kemal Serdaroğlu Lectures: Mon: 11:00-12:50, Tue:11:00-11:50 Labs: Wed 14:00-16:00, Thu: 16:00-18:00 Prerequisites:CSE 211, CSE 232 CSE 323 (strongly recommended) CSE 331 Operating Systems Design
Course Mechanics GRADING & EXAMS Final: 30%, Midterm I & Midterm II: 20%, Quizzes: 5%, Assignments, Term project and Lab exam: 25%. Midterms :(1) April 1, 2013 (2) May 7, 2013 Lab Exam: Final Exam week CSE 331 Operating Systems Design
Course Material • A.Silberschatz et al, “Operating System Concepts”, • A. Tanenbaum, “Modern Operating Systems”, • Gary Nutt, “Operating Systems, • Lecture Notes: http://cse.yeditepe.edu.tr/v2/en/academic/course-pages • Lab material: http://cse.yeditepe.edu.tr/v2/en/academic/course-pages CSE 331 Operating Systems Design
Important Notes-1 ATTENDANCE • 80% courseattendance is mandatory • 80% labattendance is mandatory. COURSE MAIL LIST • Youmustjoincoursemailinglist (cse331@cse.yeditepe.edu.tr) fortimelyannouncements. CSE 331 Operating Systems Design
Important Notes-2 SUBMISSION RULES • Timely submission of term project and assignments is mandatory in order to take the final exam . NO EXCUSES. • Late submission for assignments: Maximum 4 overdue days . (10% grade reduction for each overdue day.) • Late submission for term projects is not allowed. CSE 331 Operating Systems Design
Course Objectives NOT TO TEACH YOU HOW TO USE AN OPERATING SYSTEM. Youalreadyhave a userperspectivefor OS. We will examine: • the way in which OS works • the algorithms and data structures inside OS • the problems, solutions and trade offs in designing OS TO ACHIEVE AN UNDERSTANDING OF HOW OPERATING SYSTEM WORKS CSE 331 Operating Systems Design
Course Learning Outcomes • Design modern operating system components, under realistic constraints and conditions, in such a way as to meet real life requirements; • Apply modern operating system design methodologies for this purpose. • Use modern operating system techniques and tools for the design of multi-processing and multi-threaded applications. • Conduct experiments, gather data, analyze and interpret results for investigating engineering solutions to OS design problems. • Work efficiently in intra-disciplinary teams; work individually. CSE 331 Operating Systems Design
At the end of the course • You will understand how computers work with this priviledged software • You will learn how OS provides abstraction: illusion of infinite resources (CPU, memory etc) • You will understand the division of responsibilities between HW and SW • You will experiment with a a real OS and learn how to modify it. • You will learn designing a benchmark for testing. CSE 331 Operating Systems Design
Program Outcomes-1 • Ability to design a complex system, process, device or product under realistic constraints and conditions, in such a way as to meet the desired result; ability to apply modern design methods for this purpose. (Realistic constraints and conditions may include factors such as economic and environmental issues, sustainability, manufacturability, ethics, health, safety issues, and social and political issues, according to the nature of the design.) (Karmaşık bir sistemi, süreci, cihazı veya ürünü gerçekçi kısıtlar ve koşullar altında, belirli gereksinimleri karşılayacak şekilde tasarlama becerisi; bu amaçla modern tasarım yöntemlerini uygulama becerisi. (Gerçekçi kısıtlar ve koşullar tasarımın niteliğine göre, ekonomi, çevre sorunları, sürdürülebilirlik, üretilebilirlik, etik, sağlık, güvenlik, sosyal ve politik sorunlar gibi öğeleri içerirler). CSE 331 Operating Systems Design
Program Outcomes-2 • Ability to devise, select, and use modern techniques and tools needed for engineering practice; ability to employ information technologies effectively. (Mühendislik uygulamaları için gerekli olan modern teknik ve araçları geliştirme, seçme ve kullanma becerisi; bilişim teknolojilerini etkin bir şekilde kullanma becerisi.) • Ability to design and conduct experiments, gather data, analyze and interpret results for investigating engineering problems. (Mühendislik problemlerinin incelenmesi için deney tasarlama, deney yapma, veri toplama, sonuçları analiz etme ve yorumlama becerisi.) • Ability to work efficiently in intra-disciplinary teams; ability to work individually. (Disiplin içi takımlarda etkin biçimde çalışabilme becerisi; bireysel çalışma becerisi.) CSE 331 Operating Systems Design
INTRODUCTION CSE 331 Operating Systems Design
Why is OS Important? • The operating system is the foundation upon which all computing work is performed. • Knowledge of the internals of an OS is essential to achieve efficiency in • building software applications • deciding upon the most suitable platform for the applications • Even so, OS is pure overhead of real work • Application programs have the real value toperson who buys the computer CSE 331 Operating Systems Design
Computer System Components APPLICATION SOFTWARE SYSTEM SOFTWARE PHYSICAL HARDWARE • Application Software : Bank automation system, airlinereservations, games, payroll etc. (automated information processing and exchange) • System Software : Independent of applications, but common to all: OS, DBMS, compilers, editors , C library functions, window system, etc. CSE 331 Operating Systems Design
What is an Operating System? • A small, complex software • It has two main purposes • An interface between the user and the hardware • Provide efficient, safe management of computing resources • An OS creates resource abstractions • An OS manages resource sharing CSE 331 Operating Systems Design
Life without an OS • Every programmer would • have to know the hardware • be able to access the hardware • Every program • would contain code to do the same thing • probably do something wrong CSE 331 Operating Systems Design
Resource Abstraction (Disk) load(block, length, device); seek(device, 236); out(device, 9) ---------------------------------- write (char *block, int len, int device, int track, int sector) { ... load(block, length, device); seek(device, 236); out(device, 9); ... } ------------------------------------- write(char *block, int len, int device,int addr); ------------------------------------- fprintf(fileID, ‘‘%d’’, data); CSE 331 Operating Systems Design
Resource Sharing • Space- vs time-multiplexed sharing • To control sharing, must be able to isolate • OS usually provides mechanism to isolate, then selectively allows sharing • How to isolate resources • How to be sure that sharing is acceptable • Concurrency CSE 331 Operating Systems Design
Multiprogramming • Technique for sharing the CPU amongrunnable processes • Process may be blocked on I/O • Process may be blocked waiting for other resource • While one process is blocked, anothershould be able to run • Multiprogramming OS accomplishes CPU sharing ‘’automatically’’ • Reduced time to run all processes • Processes are sequential execution streams CSE 331 Operating Systems Design
How Multiprogramming Works process 1 process 2 Time-multiplexed CPU process n Space-multiplexed-memory CSE 331 Operating Systems Design
OS Strategies • Batch processing • Timesharing • Personal computer & workstations • Process control & real-time • Network • Distributed CSE 331 Operating Systems Design
Batch Processing • Uses multiprogramming • Job (file of OS commands) prepared offline • Batch of jobs given to OS at one time • OS processes jobs one-after-the-other • No human-computer interaction • OS optimizes resource utilization • Batch processing (as an option) still used • today CSE 331 Operating Systems Design
Timesharing • Uses multiprogramming • Support interactive computing model • Different scheduling & memory allocation strategies than batch • Uses process abstraction • Considerable attention to resource isolation (security & protection) • Tends to optimize response time CSE 331 Operating Systems Design
Personal Computers • CPU sharing among one person’s processes • Power of computing for personal tasks • Graphics • Multimedia • Trend towards very small OS • OS focuses on resource abstraction • Rapidly evolved to ‘personal multitasking’ systems CSE 331 Operating Systems Design
Process Control & Real-Time • Computer is dedicated to a single purpose • Classic embedded system • Must respond to external stimuli in fixed time • Continuous media popularizing real-time techniques • An area of growing interest CSE 331 Operating Systems Design
Networks • LAN (Local Area Network) evolution • 3Mbps (1975) -> 10 Mbps (1980)->100Mbps (1990) • High speed communication means new way to do computing • Shared files • Shared memory • ??? • Wireless Networks and Mobile Systems CSE 331 Operating Systems Design
Distributed OS Apps ……… Apps Distributed OS Multipleautonomouscomputers CSE 331 Operating Systems Design
Examples of Modern OS • UNIX variants -- have evolved since 1970 • Windows variants • Research OS -- still evolving We use Linux as main example in this course CSE 331 Operating Systems Design
Where does the OS Fit? System Calls Users and User Programs Operating System CPU & Memory Hardware I/O Devices CSE 331 Operating Systems Design
Important Points • OS provides • a simpler, more powerful interface • higher level services • OS services only accessed via system calls • Users and programs can’t directly access the hardware Set of System Calls (APIs) is what programs think the operating system is CSE 331 Operating Systems Design
Some OS Concepts • Kernel • The main OS program. Contains code for most services. Always in primary memory • Device Drivers • Programs that provide a simple, consistent interface to I/O devices • Typically part of the kernel CSE 331 Operating Systems Design
Some OS Concepts • Program • A static file of machine code on a disk • Process • A program in execution. • The collection of OS data structures and resources owned by a program while it is running. CSE 331 Operating Systems Design
Producing an Executable Source Code Object File Executable Compile Link Libraries and other Object files CSE 331 Operating Systems Design
User Program #2 User Mode RAM 1. Program performs trap 2. OS determines service number 3. Service is located and executed. 4. Control returns to user program. User Program #1 trap 002 4 1 3 Based on a diagram from “Modern Operating Systems” by Andrew Tanenbaum. 2 Kernel System/Kernel Mode CSE 331 Operating Systems Design
#include <sys/types.h> • #include <dirent.h> • #include "ourhdr.h" • int main(int argc, char *argv[]) • { • DIR *dp; • struct dirent *dirp; • if (argc != 2) • err_quit("a single argument (the directory name) is required"); • if ( (dp = opendir(argv[1])) == NULL) • err_sys("can't open %s", argv[1]); • while ( (dirp = readdir(dp)) != NULL) • printf("%s\n", dirp->d_name); • closedir(dp); • exit(0); • } CSE 331 Operating Systems Design
#include <sys/types.h> • #include <dirent.h> • #include "ourhdr.h" • int main(int argc, char *argv[]) • { • DIR *dp; • struct dirent *dirp; • if (argc != 2) • err_quit("a single argument (the directory name) is required"); • if ( (dp = opendir(argv[1])) == NULL) • err_sys("can't open %s", argv[1]); • while ( (dirp = readdir(dp)) != NULL) • printf("%s\n", dirp->d_name); • closedir(dp); • exit(0); • } Functions supplied by system libraries. These functions will contain a trap instruction. CSE 331 Operating Systems Design
OS Structures • Monolithic systems • Micro-kernel (client/server) model CSE 331 Operating Systems Design
SC Program Interrupt Handler Service routine Monolithic System • OS has no structure but is a collection of procedures with well defined calling interfaces • Program - OS interface is via system calls • UNIX kernel is monolithic CSE 331 Operating Systems Design
OS code is a binded object program and its source code may be logically divided into • OS main program • System call service routines • Utility procedures which help service routines CSE 331 Operating Systems Design
What is wrong? • OS is one large program that provides all the required services. • Anytime you add a new device you must • get a device driver for the device • recompile the kernel with the new device driver • reboot the machine so the new kernel will be used CSE 331 Operating Systems Design
SUMMARY • OS- Resource Coordinator • Resource Abstraction • Resource Sharing • Resource Allocation MODERN OS DESIGN HW REQUIREMENTS: • SOFTWARE INTERRUPT (Trap Inst.) • DUAL MODE OPERATION(Kernel/User) CSE 331 Operating Systems Design
Components of an OS • Process Management + • Interprocess Comm. Mechanisms • Synchronization Mechanisms • CPU Scheduling • Memory Management + • File Management + • Secondary Storage Management • Disk Allocation/Scheduling • Naming and Directories • I/O Management - CSE 331 Operating Systems Design