1
KUMO B4 shuya
Ritchie, O. M., and Ken Thompson. “The UNIX time-sharing system.”
The Bell System Technical Journal 57.6 (1978): 1905-1929.
2
UNIX is general-purpose, multi-user, interactive OS
A hierarchical file system incorporating demountable volumes

Compatible file, device, and inter-process I/O

The ability to initiate asynchro- nous processes 

System command language select- able on a per-user basis 

Over 100 subsystems including a dozen languages
3
UNIX the system are simple, elegance, ease of use
First UNIX is installed on DEC PDP-11/40 computer

Powerful operating system for interactive use

Not expensive either in equipment ($4,000) or in human effort

These programs are available under UNIX

- assembler, text editor, link loader, compiler…

All UNIX software is maintained under UNIX PDP-11/40
http://webpages.charter.net/thecomputercollection/pdp11/pdp1140.jpg
4
PDP-11/45 UNIX installed Computer

- 16-bit word (8-bit byte) computer, Core memory 144K bytes

- UNIX occupies 42K bytes

UNIX occupies 42K bytes

The minimum configuration require 50K bytes of core
The minimal system capable of running the software
5
The size of UNIX written in C is one third greater than old one

which written in assembly.

New system is not only easier to understand and to modify

but also many functional improvements

- multiprogramming, can share reentrant code
UNIX software is written in C language
6
Ordinary Files
- A file contains whatever information the user places on it

Directories
- Files for managing regular files and special files

Special Files
- Treat peripheral devices as virtual files
UNIX has three file system
7
Ordinary Files
A file contains whatever information the user places on it

Ex. -> symbolic or binary programs

System don’t expect file structure.

Structure of files is controlled by programs not by system
8
Directories
It provide mapping between file names and themselves

Each user has a directory of his own files and 

can create subdirectories

Several directories is maintained by system for its own use

- root - all files can be found by tracing a path through

Files are named by sequence of 14 fewer characters
9
Directories
Directory names are separated by slash “/”

- If the sequence begin with slash, search begin in “root”

- Not starting with slash, search begin in current directory

The name “.” in each directory refers to directory itself

The name “..” in each directory refers to its parent

Same nondirectory file may appear in several directories

which called linking
10
“root” is stored on same device but it is not necessary that

the entire file system hierarchy reside on this device

Mount replaces a leaf of the hierarchy tree by new subtree

After the mount, there is virtually no distinction between files

on the removable volume and parent file system

No link may exist between one file system hierarchy and 

another
11
Access control scheme in UNIX is quite simple
Each user is assigned a unique user ID number

When a file is created, it is marked with ID of its owner

Also given for new files is set of seven protection bits

Privileged programs are not accessed by other users

The system recognizes “super-user” as except from the usual

constraints on file access
12
System calls todo I/O of UNIX is quite simple
filep = open (name, flag)
- filep is called file descriptor which is used to identify to
read, write, manipulate

- name indicates the name of the file 

- flag indicates file status such as read, write

location = seek (filep, base, offset)
- offset indicates starting points and base indicates
destination
13
System calls todo I/O of UNIX is quite simple
n = read (filep, buffer, count)
n = write (filep, buffer, count)
- n is the number of bytes transmitted

- buffer is is specified byte array

- count is number of bytes to receive / send

write case, n is the same as count
read case, n is less than count when read call returns equal to
zero it indicates the end of the file
14
Data structure of UNIX file system
Directory entry contains only a name for the associated file

and pointer which integer is called “i-number” (index number)

“i-list” stored the device on which the directory resides 

when the file is accessed

“i-node” contains the description of the file as follow

- owner, protection, address, size, last modification …
15
An image is a computer excitation environment

- An image is current state of pseudo computer

- core image, general register values, status of files ...

An process is the execution of an image

- During processing, image resides in core

An image is divided into [text, data, stack] segments

- Machine instruction is placed in text segment
- Data (variables on heap) is placed in data segment
- Stack segment is place for stack, auto variables placed in
16
New process is presented by only by fork system call
processid = fork (label)
When fork is executed by a process, it spills into two process 

- parent, control returns directly from fork

- child, control is passed to location label

The processid is the identification of the other program
fork may determine whether process is the parent or child
17
pipe is used for interprocess communication
filep = pipe ( )
- It returns filep and creates interprocess channel called pipe
- pipe is passed from parent to child process in the image

by the fork call

- One pipe returns two file descriptor (for read and write)
18
Requests the system to read in and execute program
execute (file, arg1, arg2, …, argn)
- arg1 is the same string as file, so that program may
determine the name by which it was invoked

- All the code and data in the process using excuse is
replaced from file
19
processid = wait ( )
- wait suspend execution until its children has completed
execution

- It returns the processid of the terminated process

exit (status)
- exit terminates a process, destroy its image, close its files

- Process may also terminate as result of various illegal
actions or user-granted signals
20
When communicate UNIX, the Shell is helpful
The shell is command line interpreter

command arg1, arg2, …, argn
- Command line consist of command name and arguments

- The command name and arguments separated by spaces

The site of command
- Directory /bin contains all the commands generally used

- Path of command may be including “/” character to specify
21
No special coding is needed handling I/O redirection
The shell start with two files which have file descriptor 0, 1

- 0 is for reading, programs read massages typed by users

- 1 is for writing, understood as the standard output

The shell can change standard assignments of file descriptor

The file name following “<” and “>” are called redirect

- “<” means place out put 

- “>” take input followed arguments
22
Example of Standard I/O use
$ ls >there
- Create a file called “there” and places the listing

$ ed <script
- It interprets script as a file of editor command
Execution Example
23
Filter copies standard input to its standard output
A sequence of commands separated by vertical vars causes
to execute simultaneously and standard out put of each
commands is delivered to the next commands.

$ cat /var/log/secure | grep sudo > sudo_result
- $ cat /var/log/secure > temp1

- $ grep sudo < temp1 > temp2

- $ sudo_result < temp2
Example
Divided…
24
The shell is itself a command
$ ls; ed
- With semicolon when ls ends, ed is executed

$ as source >output &
- Assembling source and diagnostic output going to output
$ as source >output & ls >files &
- Both assembly and listing in the background
$ (date; ls) >x &
- Print current date followed by listing output going to x
25
Sequential use of commands
$ as source

$ mv a.out testprog

$ testprog

as assembles code and output a.out (binary)

mv causes a.out to be renamed testprog

testprog executes itself

$ sh <tryout

sh to excute the commands sequentially
26
Waiting
read return
Analyze
command
line
fork called
How to work the Shell
The new-line character

ending the line is typed
Putting the arguments

in a form for execute
fork childfork parent
wait
exec
exit
Die process
2727
When a process is created by the fork primitive

- It inherits the core image, all open files in parents with file
descriptor

- Its child process automatically inherits file descriptor value

When a n argument with “<” or “>” is given

- Offspring process, before it execute, makes the standard 

I/O file descriptor 0 or 1 respectively refer to the named file

Terminate point

- Discovering an end of file, the Shell terminates
28
init creates one process for each typewriter channel
The last step in the initialization of UNIX is the creation of a 

single process and invocation of a program called init.

When init was invoked there were no files open, in each 

process I/O devices will receive 0 or 1 file descriptor.

When user typed correct login name and password, init will 

wake up and change the user’s default current directory.

Logout need only type the end of the file sequence.
29
Faults cause the processor to trap to a system routine
Faults are such as..

- Referring nonsexist memory, unimplemented instruction…

When an illegal action is caught, the system terminates the 

process and writes the user’s image on file core

A debugger can be used to determine faults

“deletes” is interrupt signal which simply cease execution

quit signal is also used to force a core image to be produced
30
Three consideration influenced the design of UNIX
❶ From programmers perspective…

- Interactive system is much more productive and satisfying to 

use than a “batch” system

❷ Severe regulation of system an d its software

- The size constraint made economy and elegance of design.

❸ UNIX is able to maintain themselves

- Programs are always available and modified online, we were 

willing to rewrite the system when new idea were invented

Summarized of UNIX Time Sharing System

  • 1.
    1 KUMO B4 shuya Ritchie,O. M., and Ken Thompson. “The UNIX time-sharing system.” The Bell System Technical Journal 57.6 (1978): 1905-1929.
  • 2.
    2 UNIX is general-purpose,multi-user, interactive OS A hierarchical file system incorporating demountable volumes Compatible file, device, and inter-process I/O The ability to initiate asynchro- nous processes System command language select- able on a per-user basis Over 100 subsystems including a dozen languages
  • 3.
    3 UNIX the systemare simple, elegance, ease of use First UNIX is installed on DEC PDP-11/40 computer Powerful operating system for interactive use Not expensive either in equipment ($4,000) or in human effort These programs are available under UNIX - assembler, text editor, link loader, compiler… All UNIX software is maintained under UNIX PDP-11/40 http://webpages.charter.net/thecomputercollection/pdp11/pdp1140.jpg
  • 4.
    4 PDP-11/45 UNIX installedComputer - 16-bit word (8-bit byte) computer, Core memory 144K bytes - UNIX occupies 42K bytes UNIX occupies 42K bytes The minimum configuration require 50K bytes of core The minimal system capable of running the software
  • 5.
    5 The size ofUNIX written in C is one third greater than old one
 which written in assembly. New system is not only easier to understand and to modify
 but also many functional improvements - multiprogramming, can share reentrant code UNIX software is written in C language
  • 6.
    6 Ordinary Files - Afile contains whatever information the user places on it Directories - Files for managing regular files and special files Special Files - Treat peripheral devices as virtual files UNIX has three file system
  • 7.
    7 Ordinary Files A filecontains whatever information the user places on it Ex. -> symbolic or binary programs System don’t expect file structure. Structure of files is controlled by programs not by system
  • 8.
    8 Directories It provide mappingbetween file names and themselves Each user has a directory of his own files and 
 can create subdirectories Several directories is maintained by system for its own use - root - all files can be found by tracing a path through Files are named by sequence of 14 fewer characters
  • 9.
    9 Directories Directory names areseparated by slash “/” - If the sequence begin with slash, search begin in “root” - Not starting with slash, search begin in current directory The name “.” in each directory refers to directory itself The name “..” in each directory refers to its parent Same nondirectory file may appear in several directories
 which called linking
  • 10.
    10 “root” is storedon same device but it is not necessary that
 the entire file system hierarchy reside on this device Mount replaces a leaf of the hierarchy tree by new subtree After the mount, there is virtually no distinction between files
 on the removable volume and parent file system No link may exist between one file system hierarchy and 
 another
  • 11.
    11 Access control schemein UNIX is quite simple Each user is assigned a unique user ID number When a file is created, it is marked with ID of its owner Also given for new files is set of seven protection bits Privileged programs are not accessed by other users The system recognizes “super-user” as except from the usual
 constraints on file access
  • 12.
    12 System calls todoI/O of UNIX is quite simple filep = open (name, flag) - filep is called file descriptor which is used to identify to read, write, manipulate - name indicates the name of the file - flag indicates file status such as read, write location = seek (filep, base, offset) - offset indicates starting points and base indicates destination
  • 13.
    13 System calls todoI/O of UNIX is quite simple n = read (filep, buffer, count) n = write (filep, buffer, count) - n is the number of bytes transmitted - buffer is is specified byte array - count is number of bytes to receive / send write case, n is the same as count read case, n is less than count when read call returns equal to zero it indicates the end of the file
  • 14.
    14 Data structure ofUNIX file system Directory entry contains only a name for the associated file
 and pointer which integer is called “i-number” (index number) “i-list” stored the device on which the directory resides 
 when the file is accessed “i-node” contains the description of the file as follow - owner, protection, address, size, last modification …
  • 15.
    15 An image isa computer excitation environment - An image is current state of pseudo computer - core image, general register values, status of files ... An process is the execution of an image - During processing, image resides in core An image is divided into [text, data, stack] segments - Machine instruction is placed in text segment - Data (variables on heap) is placed in data segment - Stack segment is place for stack, auto variables placed in
  • 16.
    16 New process ispresented by only by fork system call processid = fork (label) When fork is executed by a process, it spills into two process - parent, control returns directly from fork - child, control is passed to location label The processid is the identification of the other program fork may determine whether process is the parent or child
  • 17.
    17 pipe is usedfor interprocess communication filep = pipe ( ) - It returns filep and creates interprocess channel called pipe - pipe is passed from parent to child process in the image
 by the fork call - One pipe returns two file descriptor (for read and write)
  • 18.
    18 Requests the systemto read in and execute program execute (file, arg1, arg2, …, argn) - arg1 is the same string as file, so that program may determine the name by which it was invoked - All the code and data in the process using excuse is replaced from file
  • 19.
    19 processid = wait( ) - wait suspend execution until its children has completed execution - It returns the processid of the terminated process exit (status) - exit terminates a process, destroy its image, close its files - Process may also terminate as result of various illegal actions or user-granted signals
  • 20.
    20 When communicate UNIX,the Shell is helpful The shell is command line interpreter command arg1, arg2, …, argn - Command line consist of command name and arguments - The command name and arguments separated by spaces The site of command - Directory /bin contains all the commands generally used - Path of command may be including “/” character to specify
  • 21.
    21 No special codingis needed handling I/O redirection The shell start with two files which have file descriptor 0, 1 - 0 is for reading, programs read massages typed by users - 1 is for writing, understood as the standard output The shell can change standard assignments of file descriptor The file name following “<” and “>” are called redirect - “<” means place out put - “>” take input followed arguments
  • 22.
    22 Example of StandardI/O use $ ls >there - Create a file called “there” and places the listing $ ed <script - It interprets script as a file of editor command Execution Example
  • 23.
    23 Filter copies standardinput to its standard output A sequence of commands separated by vertical vars causes to execute simultaneously and standard out put of each commands is delivered to the next commands. $ cat /var/log/secure | grep sudo > sudo_result - $ cat /var/log/secure > temp1 - $ grep sudo < temp1 > temp2 - $ sudo_result < temp2 Example Divided…
  • 24.
    24 The shell isitself a command $ ls; ed - With semicolon when ls ends, ed is executed $ as source >output & - Assembling source and diagnostic output going to output $ as source >output & ls >files & - Both assembly and listing in the background $ (date; ls) >x & - Print current date followed by listing output going to x
  • 25.
    25 Sequential use ofcommands $ as source $ mv a.out testprog $ testprog as assembles code and output a.out (binary) mv causes a.out to be renamed testprog testprog executes itself $ sh <tryout sh to excute the commands sequentially
  • 26.
    26 Waiting read return Analyze command line fork called Howto work the Shell The new-line character
 ending the line is typed Putting the arguments in a form for execute fork childfork parent wait exec exit Die process
  • 27.
    2727 When a processis created by the fork primitive - It inherits the core image, all open files in parents with file descriptor - Its child process automatically inherits file descriptor value When a n argument with “<” or “>” is given - Offspring process, before it execute, makes the standard 
 I/O file descriptor 0 or 1 respectively refer to the named file Terminate point - Discovering an end of file, the Shell terminates
  • 28.
    28 init creates oneprocess for each typewriter channel The last step in the initialization of UNIX is the creation of a 
 single process and invocation of a program called init. When init was invoked there were no files open, in each 
 process I/O devices will receive 0 or 1 file descriptor. When user typed correct login name and password, init will 
 wake up and change the user’s default current directory. Logout need only type the end of the file sequence.
  • 29.
    29 Faults cause theprocessor to trap to a system routine Faults are such as.. - Referring nonsexist memory, unimplemented instruction… When an illegal action is caught, the system terminates the 
 process and writes the user’s image on file core A debugger can be used to determine faults “deletes” is interrupt signal which simply cease execution quit signal is also used to force a core image to be produced
  • 30.
    30 Three consideration influencedthe design of UNIX ❶ From programmers perspective… - Interactive system is much more productive and satisfying to 
 use than a “batch” system ❷ Severe regulation of system an d its software - The size constraint made economy and elegance of design. ❸ UNIX is able to maintain themselves - Programs are always available and modified online, we were 
 willing to rewrite the system when new idea were invented