Introduction

advertisement
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
1
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
2
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
3
Important Notes-1
ATTENDANCE
• 80% course attendance is mandatory
• 80% lab attendance is mandatory.
COURSE MAIL LIST
• You must join course mailing list
(cse331@cse.yeditepe.edu.tr) for timely
announcements.
CSE 331 Operating Systems Design
4
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
5
Course Objectives
NOT TO TEACH YOU HOW TO USE AN OPERATING
SYSTEM.
You already have a user perspective for 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
6
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
7
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
8
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
9
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
10
INTRODUCTION
CSE 331 Operating Systems Design
11
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 to
person who buys the computer
CSE 331 Operating Systems Design
12
Computer System Components
APPLICATION SOFTWARE
SYSTEM SOFTWARE
PHYSICAL HARDWARE
• Application Software : Bank automation system, airline
reservations, 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
13
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
14
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
15
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
16
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
17
Multiprogramming
• Technique for sharing the CPU among runnable processes
– Process may be blocked on I/O
– Process may be blocked waiting for other resource
• While one process is blocked, another should 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
18
How Multiprogramming Works
process 1
process 2
Time-multiplexed CPU
process n
Space-multiplexed-memory
CSE 331 Operating Systems Design
19
OS Strategies
•
•
•
•
•
•
Batch processing
Timesharing
Personal computer & workstations
Process control & real-time
Network
Distributed
CSE 331 Operating Systems Design
20
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
21
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
22
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
23
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
24
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
25
Distributed OS
Apps
………
Apps
Distributed OS
Multiple autonomous computers
CSE 331 Operating Systems Design
26
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
27
Where does the OS Fit?
System Calls
Users and User Programs
Operating System
CPU & Memory
I/O Devices
CSE 331 Operating Systems Design
Hardware
28
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
29
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
30
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
31
Producing an Executable
Source Code
Object File
Compile
Executable
Link
Libraries and
other Object files
CSE 331 Operating Systems Design
32
User Program #2
RAM
User Program #1
trap 002
4
1
3
User Mode
1. Program performs trap
2. OS determines service
number
3. Service is located and
executed.
4. Control returns to user
program.
Based on a diagram from
“Modern Operating Systems” by
Andrew Tanenbaum.
2
Kernel
CSE 331 Operating Systems Design
System/Kernel Mode
33
#include
#include
#include
<sys/types.h>
<dirent.h>
"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
34
#include
#include
#include
<sys/types.h>
<dirent.h>
"ourhdr.h"
int main(int argc, char *argv[])
{
DIR
*dp;
struct dirent *dirp;
Functions supplied by system
libraries.
These functions will contain a
trap instruction.
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
35
OS Structures
• Monolithic systems
• Micro-kernel (client/server) model
CSE 331 Operating Systems Design
36
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
SC
Program
Interrupt
Handler
CSE 331 Operating Systems Design
Service routine
37
• 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
38
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
39
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
40
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
41
Download