0% found this document useful (0 votes)
3 views46 pages

Os2 p1c2 Operatingsystemstructures

The document outlines the services provided by operating systems, including functional services like program execution and I/O operations, as well as non-functional services such as resource allocation and security. It discusses system calls, their types, and the differences between APIs and system call interfaces. Additionally, it covers various operating system structures, including simple, layered, microkernel, and hybrid approaches.

Uploaded by

nghi.ngotieu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views46 pages

Os2 p1c2 Operatingsystemstructures

The document outlines the services provided by operating systems, including functional services like program execution and I/O operations, as well as non-functional services such as resource allocation and security. It discusses system calls, their types, and the differences between APIs and system call interfaces. Additionally, it covers various operating system structures, including simple, layered, microkernel, and hybrid approaches.

Uploaded by

nghi.ngotieu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Operating system structures

Tran, Van Hoai

Faculty of Computer Science & Engineering


HCMC University of Technology

E-mail: [email protected]
(partly based on slides of Le Thanh Van)

1 / 47
Outline

1 Operating system services

2 System calls and programs

3 Operating system structure

4 Advanced issues

2 / 47
Outline

1 Operating system services

2 System calls and programs

3 Operating system structure

4 Advanced issues

3 / 47
Operating system services

4 / 47
Operating system services

Functional services Non-functional services

5 / 47
Operating system services

Functional services Non-functional services


User interface (Graphical User Interface, Resource allocation,
Batch Interface, Command Line Interface), Accounting, Protection
Program execution, I/O operations, and Security
File-system manipulation,
Communications, Error detection
6 / 47
Functional services
Program execution

What is a program ?
A computer program is a collection of instructions that
performs a specific task when executed by a computer.

7 / 47
Functional services
Program execution

What is a program ?
A computer program is a collection of instructions that
performs a specific task when executed by a computer.

OS is able to load a program into memory and to run


that program
The program is able to end its execution (either normally
or abnormally)

8 / 47
Functional services
I/O operations & File-system manipulation

I/O operations
A running program may access I/O devices, e.g.,
recording DVD)
For efficiency and protection, OS must provide a means
(for programs) to do I/O

9 / 47
Functional services
I/O operations & File-system manipulation

I/O operations
A running program may access I/O devices, e.g.,
recording DVD)
For efficiency and protection, OS must provide a means
(for programs) to do I/O

File-system manipulation
Programs need operations on files/directories: list, create,
delete, read, write, permission management

10 / 47
Functional services
Communications

There are many communications


between running programs on a machine
between running program on different machines
There are two main types of communications
shared memory: read/write on a shared of memory
message passing: packets with predefined formats are
exchanged between running programs
Running program A Running program B

Shared memory

11 / 47
Functional services
Communications

There are many communications


between running programs on a machine
between running program on different machines
There are two main types of communications
shared memory: read/write on a shared of memory
message passing: packets with predefined formats are
exchanged between running programs
Running program A Running program B

A copies value into mem

Shared memory

12 / 47
Functional services
Communications

There are many communications


between running programs on a machine
between running program on different machines
There are two main types of communications
shared memory: read/write on a shared of memory
message passing: packets with predefined formats are
exchanged between running programs
Running program A Running program B

B copies value from mem

Shared memory

13 / 47
Functional services
Communications

There are many communications


between running programs on a machine
between running program on different machines
There are two main types of communications
shared memory: read/write on a shared of memory
message passing: packets with predefined formats are
exchanged between running programs
Running program A Running program B

B copies value from mem

Shared memory
Running program A Running program B

A sends packet containing value to B

Interconnect

14 / 47
Functional services
Error detection

Errors can occur everywhere


Hardware: CPU, memory, I/O devices,...
User program: arithmetic overflow, illegal access of
memory, division by zero,...
OS should take appropriate actions to detect and correct
errors constantly.

15 / 47
Non-functional services

Resource allocation
OS manages multiple resources (hardware, software) and
allocates them to multiple users and multiple running
programs
Special codes are needed to make allocation efficiently,
e.g., CPU scheduling, printers allocation

Accounting
Recording which users to use how much and what kind of resources
Usage statistics is useful to reconfigure for improvement of
computing services

Protection and security


Information of multiple users on a networked computer should be
controlled by its owner.
16 / 47
User interface

Command interpreter - a special program to allows users


to directly enter commands (or programs) (by text) to be
performed by the operating system

Multiple command
interpreters (also
shell) in a modern
operating system
Example: Bourne shell,
Bash shell, C shell,
Bourne-Again shell, Korn
shell

17 / 47
User interface

Command interpreter - a special program to allows users


to directly enter commands (or programs) (by text) to be
performed by the operating system

Multiple command
interpreters (also
shell) in a modern
operating system
Example: Bourne shell,
Bash shell, C shell,
Bourne-Again shell, Korn
shell
GUI - a user friendly graphical interface, input/output is
performed in a more interactive way

18 / 47
Choice of interface

Interface choice
Kind of interface (CLI or GUI) is mostly one of personal
preference

System administratiors or power users often prefer CLI


With deep system knowledge, using CLI is more efficient
and secure
Multiple shell commands can be combined into a
program, called shell script to perform more complex
tasks.
Normal users often choose GUI

19 / 47
Choice of interface

Interface choice
Kind of interface (CLI or GUI) is mostly one of personal
preference

System administratiors or power users often prefer CLI


With deep system knowledge, using CLI is more efficient
and secure
Multiple shell commands can be combined into a
program, called shell script to perform more complex
tasks.
Normal users often choose GUI

UI can vary from system to system. Therefore, it is not a


direct function of operating system.

20 / 47
Outline

1 Operating system services

2 System calls and programs

3 Operating system structure

4 Advanced issues

21 / 47
Example on system call demand
File-to-file copy

22 / 47
Example on system call demand
File-to-file copy

Even a simple program executes many system calls

23 / 47
API vs. system call interface

Application Programming Interface (API)


Set of functions available to application programmers

Using API to increase program portability: ability to


compile and run on systems with the same API without
code modification
Working with API is easier than with actual system calls
3 most common APIs: Windows API, POSIX API, Java
API
System-call interface
A run-time support system (e.g., libc) serves as a link
between API and system calls in operating system

Each system call is identified by an index number


24 / 47
A call to system call open()

25 / 47
A call to system call open()

Standard API System call

26 / 47
Parameters passing to system call

There are 3 ways.


By registers: not enough for large parameters
Stored in block (or table), passing address of the block in
parameter

Pushed onto program’s stack, and popped off by OS

27 / 47
Types of system calls

Process control
File management
Device management
Information maintenance
Communications
Protection

28 / 47
Process control

What is a program ?
A computer program is a collection of instructions that
performs a specific task when executed by a computer.

What is a process ?
A program loaded into memory and executing is called a
process

end(), abort() wait_for_time()


load(), execute() wait_event(), signal_event()
create_process(), allocate and free memory
terminate_process()
get_process_attributes(),
set_process_attributes()

29 / 47
Execution on single-task OS
MS-DOS

At system startup Running a program

30 / 47
Execution on single-task OS
MS-DOS

load program into memory

some memory of inter-


preter is overwritten

At system startup Running a program

31 / 47
Execution on multiple-task OS
FreeBSD

Multiple (user) processes in


memory at the same time

32 / 47
Interprocess communication

Interprocess communication may take place using either


message passing or shared memory

33 / 47
Interprocess communication

Interprocess communication may take place using either


message passing or shared memory

Message passing Shared memory

34 / 47
System programs

System programs = system utilities


Providing a convenient environment for program development
and execution
There are categories as follows.
File manipulation
Status information
File modification
Programming-language support
Program loading and execution
Communications
Background services

35 / 47
System programs

System programs = system utilities


Providing a convenient environment for program development
and execution
There are categories as follows.
File manipulation
Status information
File modification
Programming-language support
Program loading and execution
Communications
Background services

The view of most users on the operating system is defined by


system programs, not actual system calls.

36 / 47
Outline

1 Operating system services

2 System calls and programs

3 Operating system structure

4 Advanced issues

37 / 47
Simple structure
MS-DOS

MS-DOS: written to provide the


most functionality in the least
space
not divided into modules
interfaces and levels of
functionality are not well
separated

38 / 47
Simple structure
Traditional UNIX

Limited structure with limited functionality


Consists of 2 parts: kernel and system programs

Considered to be layered to some extent: system-call inteface, kernel and


hardware interface
Enormous amount of functionality combined in one level → monolithic structure

39 / 47
Layered approach

OS is broken into several layers


Layer M provides data structures
& routines for upper layer, and
can invoke operations of lower
layer

40 / 47
Layered approach

OS is broken into several layers


Layer M provides data structures
& routines for upper layer, and
can invoke operations of lower
layer

Advantages (due to modularity): easy to Disadvantages: Not easy to define layers


debug; simple in design and (which layer is above/below which layer);
implementation; secure inefficiency

41 / 47
Microkernel structure

Moves as much from the kernel into “user” space


Communication takes place between user modules using
message passing

42 / 47
Microkernel structure

Moves as much from the kernel into “user” space


Communication takes place between user modules using
message passing

Advantages (due to modularity): easy to Disadvantages: system-function overhead


extend kernel; easier to port OS to new
architectures; more reliable (less code
running in kernel); more secure
43 / 47
Modules-based structure
Best current methodology is loadable kernel modules
Only need core services
Additional services can be loaded as modules in boot
time and run time
Additional services have to be recompiled to add new
features
Idea of modules-based kernel more flexible than layered
approach and also similar to microkernel structure

44 / 47
Hybrid structure

In practice, very few OS adopt a single, stricted defined


structure

45 / 47
Outline

1 Operating system services

2 System calls and programs

3 Operating system structure

4 Advanced issues

46 / 47

You might also like