Professional Documents
Culture Documents
Introduction
10 August, 2010
1
Instructor
Ooi Wei Tsang
ooiwt@comp.nus.edu.sg
2
Office Hour
Thu 4 - 6pm
AS6 05-14
Required Textbook
4
$ 4 7 . 0 0
Lecture
2 hr Tutorial
1 hr
Lab
1 hr
Preparation
6 hr
Note that NUS officially lists the workload as 2-1-1-0-4 which is a typo (it does not add up to 10!)
6
Assessment
Exam
50%
Midterm
20%
Participation
Lab 5%
25%
7
Important Dates
October 2010 November 2010
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6
3 4 5 6 7 8 9 7 8 9 10 11 12 13
10 11 12 13 14 15 16 14 15 16 17 18 19 20
17 18 19 20 21 22 23 21 22 23 24 25 26 27
24 25 26 27 28 29 30 28 29 30
31
midterm final
8
midterm and final are
semi-open book
(one 2-sided A4 sheet)
9
Lecture Format
Lecture Break Lecture Break Lecture Dismiss
1200-1400 35 5 35 5 30 10
0 20 40 60 80 100 120
10
slides will be posted
1-2 days before lecture
but
11
students are
expected to take
notes during lecture
12
students are
expected to read the
assigned readings
13
no “model” answer
will be posted
14
Light a Fire
Philosophy:
light fire
not fill bucket -
William Yeats
15
Philosophy:
light fire
not fill bucket -
William Yeats
Flickr
Flickrphoto
photoby
bydanielygo
peasap Some
Some
rights
rights
reserved
reserved
Not Fill a Bucket
16
blog.nus.edu.sg/cs2106
17
your responsibility: check for
update frequently
18
do participate in online
discussion
19
screencast
will be posted
20
what is
CS2106
about?
21
NOT about how to use
Mac OS X, MS Windows,
Linux etc.
22
about basic concepts
and design principles
in OS
23
why should I learn
OS ?
24
I am not gonna write another OS!
25
complex software
26
abstraction +
interface design
27
concurrency
28
resource management
29
performance trade-off
30
what to learn from OS course
(beside OS):
1. complex systems
2. abstraction + interface design
3. concurrency
4. resource management
5. performance trade-off
31
after CS2106
32
CS3221
OS Design and Pragmatics
33
CS3211
Parallel and Concurrent
Programming
34
CS4223
Parallel Computer Architecture
35
CS4275
Programming Real-Time
Systems
36
CS4344
Networked and Mobile
Gaming
37
CS5222
Processor Architecture
38
CS5223
Distributed Systems
39
CS5231
Systems Security
40
CS5248
Systems Support for
Continuous Media
41
CS6270
Virtual Machines
42
OS
Operating Systems
43
browser calendar ... media player
operating system
machine language
microarchitecture
physical devices
44
The OS is a layer of software
that manages processors,
storage and I/O devices and
provide simple interfaces to the
hardware to user programs.
45
OS
is everywhere
46
phone, car, robot, router,
media player, game
console, ..
47
48
49
consider the simple program:
50
is the file on a CD,
thumbdrive, harddisk..?
location of file on storage?
is another program writing to
the file at the same time?
etc..
51
what graphics chip is the system
using?
what is the display resolution?
is another process writing to the
same location?
etc..
52
OS
as an extended
machine
53
browser calendar ... media player
operating system
54
browser calendar .. media player user
mode
compilers editors .. shell
kernel
operating system (a.k.a kernel)
mode
55
interfaces provided by OS
are known as system calls
56
Language libraries typically
provide a 1-to-1 mapping
between library calls and system
calls.
57
Recall how a library procedure
call works..
58
CPU Memory
frame stack
pointer
stack
pointer
program
counter
data
program
status word code
59
CPU Memory
CPU
frame stack
pointer
return address
stack saved frame pointer
pointer local variables
function parameters
program
counter
data
program
status word code
60
a system call is similar, except:
1.
a special instruction sets the
kernel mode bit in PSW before
executing the system call
61
2.
a special instruction sets the
user mode bit in PSW after
executing the system call
62
3.
CPU executes the OS system
call handler.
63
In user mode, certain privileged
instructions cannot be executed,
certain addresses cannot be
accessed etc.
64
Bad things happen in older OSes
without dual mode operation.
65
Bad things still happen if buggy
code runs in kernel mode.
66
browser calendar .. media player user
mode
compilers editors .. shell
kernel
operating system (a.k.a kernel)
mode
67
OS
as a resource manager
68
operating system
processor network
disk space RAM
cycles bandwidth
screen battery
....
estate power
69
what if the computer runs one task at
a time, always completing it before
running another task ?
70
a task always have full use of all
resources.
71
Suppose the computer keeps
multiple tasks in the memory. When
the running task is idle, switch to
another task (multi-programming)
72
now, resources are shared among
the tasks.
74
The computer keeps multiple tasks in
the memory and switch between
them frequently (regardless of
whether the task is idle) (time-
sharing)
75
time-multiplexing: CPU, printer
76
OS
is an extended machine
and
a resource manager
77
UNIX and C
78
why UNIX?
(Linux, Mac OS X, Sun OS etc.)
79
many OS concepts are
cleanly manifested in UNIX
80
source code are available
81
why C?
82
UNIX is written (mostly) in C
83
intermediate-level language
(e.g., explicit memory allocation,
bits manipulation)
84
A brief introduction to
C and programming in
UNIX
85
C vs Java
(highlights)
86
Java: set of classes
87
C:
no byte datatype
no boolean datatype
no String class
88
Java: all variables are reference
except boolean and numeric types
89
C:
no “new” operator
91
Java: external classes must be
imported
92
int
main()
{
return
0;
}
93
#include
<stdio.h>
int
main()
{
printf(“Hello
World!\n”);
return
0;
}
94
to compile:
gcc hello.c
95
#include
<stdio.h>
#include
<stdlib.h>
96
*
97