Operating System_1.1
Operating System_1.1
Chapter 1
< Operating
/ System 22CSH-
} /> [
242 /
>
Presented by:
Dr. Krishnendu Rarhi
Abstraction or Virtualization
Design Goals
1 0 1 1 0 1 1 0 1 1 0 1 1 0Krishnendu
0 1 1 0 Rarhi
1 1[E9621]]©
011 011 01 110110 110111 1101
APEX Institute of Technology
</ Operating System - Examples
I/O Users
Executable The exe contains instructions that the CPU can understand, and data of the
program (all numbered with addresses)
/> ** } /> [
To run an exe, CPU Cache
– fetches instruction pointed at by PC from Most recently used instructions and data
memory are in CPU caches for faster access
– loads data required by the instructions into
registers
– decodes and executes the instruction
– stores results to memory
● Process control
○ create process, terminate process
○ end, abort
○ load, execute
○ get process attributes, set process attributes
○ wait for time
○ wait event, signal event
○ allocate and free memory
○ Dump memory if error
○ Debugger for determining bugs, single step execution
○ Locks for managing access to shared data between processes
Types of System Calls
● File management
○ create file, delete file
○ open, close file
○ read, write, reposition
○ get and set file attributes
● Device management
○ request device, release device
○ read, write, reposition
○ get device attributes, set device attributes
○ logically attach or detach devices
Types of System Calls (Cont.)
● Information maintenance
○ get time or date, set time or date
○ get system data, set system data
○ get and set process, file, or device attributes
● Communications
○ create, delete communication connection
○ send, receive messages if message passing model to
host name or process name
■ From client to server
○ Shared-memory model create and gain access to
memory regions
○ transfer status information
○ attach and detach remote devices
Types of System Calls (Cont.)
● Protection
○ Control access to resources
○ Get and set permissions
○ Allow and deny user access
Examples of Windows and Unix System Calls
System Programs
Manages CPU (Initializes program counter (PC) and other registers to begin execution)
A Running
Program
</>
1011 011 01 1011001 10 11011 011 01 110110 110111 1101
Virtualizing the CPU
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/time.h>
4 #include <assert.h>
5 #include "common.h"
6
7 int
8 main(int argc, char *argv[])
9 {
10 if (argc != 2) {
11 fprintf(stderr, "usage: cpu <string>\n");
12 exit(1);
13 }
14 char *str = argv[1];
15 while (1) {
16 Spin(1); // Repeatedly checks the time and
returns once it has run for a second
17 printf("%s\n", str);
18 }
19 return 0;
20 }
</>
1011 011 01 1011001 10 11011 011 01 110110 110111 1101
Virtualizing Memory
● A program that Accesses Memory (mem.c)
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "common.h"
5
6 int
7 main(int argc, char *argv[])
8 {
9 int *p = malloc(sizeof(int)); // a1: allocate some
memory
10 assert(p != NULL);
11 printf("(%d) address of p: %08x\n",
12 getpid(), (unsigned) p); // a2: print out the
address of the memmory
13 *p = 0; // a3: put zero into the first slot of the memory
14 while (1) {
15 Spin(1);
16 *p = *p + 1;
17 printf("(%d) p: %d\n", getpid(), *p); // a4
18 }
19 return 0;
20 }
</>
1011 011 01 1011001 10 11011 011 01 110110 110111 1101
The problem of Concurrency
● The OS is juggling many things at once, first running one process, then another, and so forth.
23 loops = atoi(argv[1]);
24 pthread_t p1, p2;
25 printf("Initial value : %d\n", counter);
26
27 Pthread_create(&p1, NULL, worker, NULL);
28 Pthread_create(&p2, NULL, worker, NULL);
29 Pthread_join(p1, NULL);
30 Pthread_join(p2, NULL);
31 printf("Final value : %d\n", counter);
32 return 0;
33 }
○ loops: 100000.
open(), write(), and close() system calls are routed to the part
of OS called the file system, which handles the requests
“The one program running at all times on the computer” is the kernel.
</>
1011 011 01 1011001 10 11011 011 01 110110 110111 1101
</ Design Goals
Reliability Other
High-degree of reliability • Energy Efficiency
by running the OS non- • Security
stop • Mobility
</>
1011 011 01 1011001 10 11011 011 01 110110 110111 1101
Kernels
● Kernel is the main part of an Operating System. It is the first program that
is loaded after the boot loader whenever we start a system. The Kernel is
present in the memory until the Operating System is shut-down.
● Kernel provides an interface between the user and the hardware
components of the system. Whenever a process makes a request to the
Kernel, then it is called System Call.
Types of Kernels
● Functions of Kernel
• Process management
• Monolithic kernel.
• Access computer resources • Micro kernel.
• Device management • Hybrid kernel.
• Memory management • Nano kernel.
• Interrupt handling
• Exo kernel
• I/O communication
Reentrant Kernels
Definition A monolithic kernel is a type of kernel in operating systems A microkernel is a kernel type that
where the entire operating system works in the kernel space. provides low-level address space
Monolithic Kernels management, thread management,
and interprocess communication to
implement an operating system.
Address In a monolithic kernel, both user services and kernel services In microkernel user services and
space are kept in the same address space. kernel, services are kept in separate
address spaces.
Size The monolithic kernel is larger than the microkernel. The microkernel is smaller in size.
Customizatio It is difficult to add new functionalities to the monolithic It is easier to add new functionalities
n kernel. Therefore, it is not customizable. to the microkernel. Therefore, it is
more customizable.
Code Less coding is required to write a monolithic kernel. A microkernel is required more coding.
Example Linux, FreeBSD, OpenBSD, NetBSD, Microsoft Windows (95, QNX, Symbian, L4L.inux, Singularity,
98, Me), Solaries, HP-UX, DOS, OpenVMS, XTS-400, etc. K42, Mac OS X, Integrity, PikeOS,
HURD, Minix, and Coyotos.
OS History
Mini computer
PDP-11
Unix
Main frame computer Shell, pipe, signal
M360
Virtual Machine