Professional Documents
Culture Documents
OS Concepts
and Structure
17 August, 2010
1
Overview of Basic
Concepts in OS
2
Recall:
Time-Sharing
3
Waiting Area
Task 3 Task 4
Task 2
Task 1
...
4
what do you need to
remember in order to
resume a task?
5
process:
code + data +
context of execution
6
example of
process-related sys calls:
fork( ) waitpid( ) exec( ) exit( )
7
how to prevent one process
from corrupting the memory of
another process?
8
every process has its own
address space
9
a process may occupy
different physical memory
location at different time
10
but the executable code
remains the same.
11
Memory
stack
CPU
data
code
12
Data on disks are organized
into files and directories
13
block special files
character special files
in
/dev
14
pipe
15
example of
file-related sys calls:
open( ) close( ) read( ) write( )
lseek( ) state( )
16
example of
file systems-related sys calls:
mkdir( ) rmdir( )
link( ) unlink( )
mount( ) umount( )
17
User interfaces to OS:
1. shell
2. window systems
18
processes
address space
files and directories
shell
19
Structure of OSes
20
Structure of
Linux Kernel
21
user program
system calls
interrupt dispatcher
hardware
22
user program
system calls
memory process
I/O component
management management
interrupt dispatcher
hardware
23
user program
system calls
memory process
management management
device drivers
interrupt dispatcher
hardware
24
such design is called
monolithic kernel
25
dynamically loadable
kernel module
keeps the kernel small, extensible
(also in MS Windows, Mac OS X)
26
Alternative to monolithic design:
microkernel
27
An example microkernel architecture
system calls
interrupt dispatcher
hardware
28
keep minimal functions in kernel
example:
29
A brief introduction to
C and programming in
UNIX
30
#include
<stdio.h>
#include
<stdlib.h>
31
to compile:
gcc hello.c
32
to debug:
gdb hello
33
int
x
=
1;
int
y
=
2;
x
=
y;
34
int
*x;
int
y
=
2;
x
=
&y;
*x
=
3;
y
=
*x;
35
int
*x;
int
y
=
2;
*x = 1;
36
int
y
=
2;
f(y);
*y
=
7;
*(y+1)
=
9
38
char
*name;
name
=
malloc(10);
strcpy(name,
“cs2106”);
:
:
free(name);
39
struct
process
{
int
pid;
char
*cmd;
int
status;
}
typedef
struct
process
proc;
40
proc*
create_process()
{
proc
*p
=
malloc(sizeof(proc));
//
initialize
fields
return
p;
}
41