0% found this document useful (0 votes)
2 views

unit-1a

The document provides an overview of UNIX, detailing its historical development from MULTICS to its implementation by Ken Thompson and Dennis Ritchie at Bell Labs. It explains the architecture of UNIX, focusing on its file and process subsystems, and describes the operating system's role as a resource manager and its execution modes. Additionally, it covers system calls, process control, memory management, and the handling of interrupts within the UNIX operating system.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

unit-1a

The document provides an overview of UNIX, detailing its historical development from MULTICS to its implementation by Ken Thompson and Dennis Ritchie at Bell Labs. It explains the architecture of UNIX, focusing on its file and process subsystems, and describes the operating system's role as a resource manager and its execution modes. Additionally, it covers system calls, process control, memory management, and the handling of interrupts within the UNIX operating system.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Introduction to UNIX

1
Brief History of UNIX

• In 1965, the project to develop MULTICS began.


– MULTiplexed Information and Computing Service
– GE, MIT, and AT&T Bell Lab.
– goal: to provide simultaneous computer access to a large
community of users similar to the electricity distribution
System

• In 1969, primitive version of MULTICS was running on


GE 645.
– but it didn’t provide general service computing.
– Bell Lab. withdrew from the project; GE quit computer
business.

• MULTICS introduced many seminal ideas into the


computer literature.

2
Brief History of UNIX

• Ken Thompson and Dennis Ritchie of Bell Lab.


implemented a new system on PDP-7, and it is named
UNIX.

• UNIX was moved to PDP-11 in 1971 and rewritten in C


in 1973.

• Through development System III, in 1983, AT&T


announced official support for System V.

• On the other hand, UCB developed 4.1BSD in 1980s.

3
Overview of hardware

4
CPU (Processor)

• General purpose registers and special registers

– general purpose registers are used for several types of execution


– program counter specifies the address of the operation code to be executed
– stack pointer specifies the address of the top of the stack
– PWS (Processor Status Word) specifies the status of the CPU

• Execution modes of the CPU


– user mode and kernel mode
– in kernel mode, all instructions including privileged instructions can be
executed.

– OS is running in kernel mode

– user program is running in user mode

5
Position of operating System

6
7
What is an Operating System?

• OS as an extended machine

– hides differences in hardware and provides an extended machine or a


virtual machine to users
– a program uses functions of the kernel through system calls

• OS as a resource manager

– allocates resources in time (e.g., CPU, printer, etc.)


– allocates resources in space (e.g., memory, disk space, etc.)

• OS in the broad sense


– applications are also included
• OS in the narrow sense
– only the basic part, called the kernel

8
Programs and Processes

• Program is a sequence of instructions


– It is saved in the disk as a command file
– e.g., “/bin/ls”

• Process is a program that is currently executed


– A program is loaded in memory and is being executed.
– A process has its context.
– There are more than one processes if the same program is
executed simultaneously.

– Resources are allocated to each process


• e.g., CPU, memory, I/O devices, etc.

9
Execution Modes

• The execution of user processes is divided into two levels:


user and kernel
– Processes in user mode can access their own instructions and
data but not kernel instructions and data

– Processes in kernel mode can access kernel and user addresses

– Some machine instructions are privileged and result in an


error when executed in user mod

10
Architecture of UNIX

• 2 central concepts: file and process

– 2 major components of the kernel:


file subsystem and process control subsystem

• 3 levels: user, kernel, and hardware


– user/kernel border: system call and library interface
– system calls look like ordinary function calls.
– libraries map these function calls to the primitives
needed to enter the operating system.
– The libraries are linked with the program at compile time
and are thus part of the user program

11
12
File Subsystem

• The file subsystem manages files, allocating file space,


administering free space, controlling access to files,
retrieving data for users.

• Processes interact with the file subsystem via system


calls such as open, close, read, write, stat, and chmod.

• The file subsystem access file data using a buffering


mechanism that regulates data flow between the kernel
and secondary storage.

• The buffering mechanism interacts with block I/O


devices drivers.

• The file subsystem also interacts with “raw” I/O device


drivers without buffering mechanism.
13
14
Storage structure on disk
15
• File identification :– path – relative and absolute
example: /etc/password
/bin/who
/ - root directory

• User is not aware of internal storage of files.

• File permissions

• Device Files.

16
17
An Example of System Calls and Library Functions

- open
main( )
- opens a file
{
(preparation for read/write)
int fd, c;
-returns a fd
char buf[512], buf2[512];
-(file descriptor)
if ((fd = open(“test.txt”, O_RDONLY)) < 0) {
- read
perror(“open”);
- reads data from the file
exit(1);
specified by fd to the buffer
}
if ((c = read(fd, buf, 512)) < 0) { - close
perror(“read”); -closes the file
exit(1);
}
close(fd); - these system calls are
bcopy(buf, buf2, 512); processed in the kernel
}
- bcopy is a library function
18
19
Building Block Primitives:

standard in, standard out, standard error

I/O Redirection

ls > dout.txt

a.out < in.txt

nroff –mm < doc1 > doc1.txt 2>error

Pipes
ls | grep httpd
20
Operating System Services:

Controlling execution of processes by allowing their


creation, termination, suspension, and communication

Scheduling processes fairly for execution on the CPU

Allocating Main memory for executing processes, swapping

Allocating secondary storage for efficient storage of user data

Allowing processes controlled access to devices such as disk,


Terminals, network, tape drives

21
Assumption about hardware:

Execution mode – User mode and kernel mode

22
Interrupts and Exceptions

UNIX allows devices to interrupt the CPU asynchronously.

On interrupt :
OS saves the context of the currently executing
Process(Frozen image of process).
Determines the Sources of interrupt

Executes the Interrupt Service Routine corresponding to


the interrupt.

Restores the context of process.

Process continues its execution as if nothing has happened.


23
Hardware usually priorities the interrupts as per their
importance (importance of the device connected to it)

24
An Example of System Calls and Library Functions

25
An Example of System Calls and Library Functions

26
Process Control Subsystem

• The process control subsystem is responsible for


process synchronization, interprocess communication,
memory management, and process scheduling.

– system calls: fork, exec, exit, wait, brk, and signal

• The file subsystem and the process control subsystem


interact when loading a file into memory for execution.

Memory Management Module

• The memory management module controls the


allocation of memory.

• If at any time the system does not have enough physical


memory for all processes, the kernel moves them
between main memory and secondary memory.
– 2 policies: swapping and demand paging
– swapper process 27
Scheduler Module

• The scheduler module allocates the CPU to processes.

• It schedules them to run in turn until they voluntarily relinquish the CPU
while awaiting a resource or until the kernel preempts them when their
recent run time exceeds a time quantum.

• The scheduler then chooses the highest priority eligible


process to run.

Other Modules
• Interprocess communication
– ranging from asynchronous signaling to synchronous transmission of messages
between processes.
• Hardware control:
– responsible for handling interrupts and for communicating with the machine.
– the kernel may resume execution of interrupted process after servicing an
interrupt.
– Interrupts are not serviced by special processes but by special
functions in the kernel, called in the context of the currently
running process. 28
29

You might also like