Lecture2 - OS Structure
Lecture2 - OS Structure
System Calls
Program I/O File Resource Error
Execution operations Systems Allocation Detection
Protection
Accounting Communication
and Security
Operating System
Hardware
• Logging - To keep track of which users use how much and what kind of
computer resources, improve response time to users
• In OS everything is a file
– Command interpreter does not understand the command (e.g. “rm”)
– It merely uses the command to identify a file to be loaded into memory and
executed.
• For example, shell would search for a file called ‘rm’, load the file into memory
and execute it with the parameter file.txt
– Thus, programmer can add new commands to the system easily by creating
new files (programs)
Operating Systems-COMP 304 8
Src code of Linux Commands
• All these basic commands are part of the coreutils
package.
– http://www.gnu.org/software/coreutils/
– commands such as rm, ls, chmod, cp …
• https://github.com/coreutils/coreutils/tree/master/src
user process
user mode
user process executing calls system call return from system call (mode bit = 1)
trap return
kernel mode bit = 0 mode bit = 1 kernel mode
(mode bit = 0)
execute system call
• Types of system calls classified under 6 categories. Table gives an example for
Windows and Unix syscalls.
Operating Systems-COMP 304 17
Privileged Instructions
• The dual mode of operation provides us with the means for
protecting the operating system from errant users—and
errant users from one another.
• We accomplish this protection by designating some of the
machine instructions that may cause harm as privileged
instructions.
– The hardware allows privileged instructions to be executed only in
kernel mode.
– If an attempt is made to execute a privileged instruction in user mode,
the hardware does not execute the instruction but rather treats it as
illegal and traps it to the operating system
300040 300040
process 2 base register
420940 120900
process 3 limit register
880000
process 4
1024000
no no memory
messages messages
microkernel
hardware
• Acknowledgments
– Original slides are by Didem Unat which were adapted from
• Öznur Özkasap (Koç University)
• Operating System and Concepts (9th edition) Wiley
31