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

OS Structure

operating system notes on topic processes

Uploaded by

Abdul Ahad
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

OS Structure

operating system notes on topic processes

Uploaded by

Abdul Ahad
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Operating System

Structure
OS Services
An operating system provides an environment for the execution of
programs by providing services to users and programs.
UI
• The three primary approaches for interacting with an operating
system are
(1) command interpreters
(2) graphical user interfaces
(3) touchscreen interfaces
System Call Example
cp in.txt out.txt (when file names read from user)
System Calls
System calls can be divided into six major categories: (1) process
control (2) file management (3) device management (4) information
maintenance (5) communications and (6) protection.

1- Process control
◦ create process terminate process
◦ load execute
◦ get process attributes set process attributes
◦ wait event signal event
◦ allocate and free memory
System Calls cont…
2- File management 3- Device management
◦ create file delete file ◦ request device release device
◦ open close ◦ read write reposition
◦ read write reposition ◦ get device attributes set
◦ get file attributes set file device attributes
attributes ◦ logically attach or detach
devices
System Calls cont…
4- Information maintenance 5- Communications
◦ get time or date set time or date ◦ create delete communication
◦ get system data set system data connection
◦ get process file or device attributes ◦ send receive messages
◦ set process file or device attributes ◦ transfer status information
◦ attach or detach remote devices
6- Protection
◦ get file permissions
◦ set file permissions
Linker &
Loader
• A linker combines several
relocatable object modules
into a single binary
executable file.
• A loader loads the
executable file into memory
making it eligible to run on
an available CPU.
Relocating Symbols and Resolving
External• Symbols
References
are lexical entities that name functions and variables.
• Each symbol has a value (typically a memory address).
• Code consists of symbol definitions and references.
• References can be either local or external.

m.c a.c
int e=7; extern int e;
Def of local
symbol e int main() { int *ep=&e; Ref to
int r = a(); int x=15; external
exit(0); int y; symbol e
} Def of
local int a() { Defs of
Ref to external symbol return *ep+x+y; local
} symbols
symbol exit Ref to external ep
(defined in x and y
symbol a Def of
libc.so) Refs of local
local
symbols epxy
symbol a
m.o Relocation Info
m.c
int e=7; Disassembly of section .text:

int main() { 00000000 <main>: 00000000 <main>:


0: 55 pushl %ebp
int r = a();
1: 89 e5 movl %esp%ebp
exit(0); 3: e8 fc ff ff ff call 4 <main+0x4>
} 4: R_386_PC32 a
8: 6a 00 pushl $0x0
a: e8 fc ff ff ff call b <main+0xb>
b: R_386_PC32 exit
f: 90 nop

Disassembly of section .data:

00000000 <e>:
0: 07 00 00 00

source: objdump
a.o Relocation Info (.text)
a.c
extern int e; Disassembly of section .text:

00000000 <a>:
int *ep=&e;
0: 55 pushl %ebp
int x=15; 1: 8b 15 00 00 00 movl 0x0%edx
int y; 6: 00
3: R_386_32 ep
int a() { 7: a1 00 00 00 00 movl 0x0%eax
return *ep+x+y; 8: R_386_32 x
} c: 89 e5 movl %esp%ebp
e: 03 02 addl (%edx)%eax
10: 89 ec movl %ebp%esp
12: 03 05 00 00 00 addl 0x0%eax
17: 00
14: R_386_32 y
18: 5d popl %ebp
19: c3 ret
a.o Relocation Info (.data)
a.c
extern int e; Disassembly of section .data:

00000000 <ep>:
int *ep=&e;
0: 00 00 00 00
int x=15; 0: R_386_32 e
int y; 00000004 <x>:
4: 0f 00 00 00
int a() {
return *ep+x+y;
}
Executable After Relocation and
External Reference Resolution (.text)
08048530 <main>:
8048530: 55 pushl %ebp
8048531: 89 e5 movl %esp%ebp
8048533: e8 08 00 00 00 call 8048540 <a>
8048538: 6a 00 pushl $0x0
804853a: e8 35 ff ff ff call 8048474 <_init+0x94>
804853f: 90 nop

08048540 <a>:
8048540: 55 pushl %ebp
8048541: 8b 15 1c a0 04 movl 0x804a01c%edx
8048546: 08
8048547: a1 20 a0 04 08 movl 0x804a020%eax
804854c: 89 e5 movl %esp%ebp
804854e: 03 02 addl (%edx)%eax
8048550: 89 ec movl %ebp%esp
8048552: 03 05 d0 a3 04 addl 0x804a3d0%eax
8048557: 08
8048558: 5d popl %ebp
8048559: c3 ret
Executable After Relocation and
External Reference Resolution(.data)
m.c
int e=7;
Disassembly of section .data:

int main() { 0804a018 <e>:


int r = a(); 804a018: 07 00 00 00
exit(0);
}

a.c 0804a01c <ep>:


extern int e; 804a01c: 18 a0 04 08

int *ep=&e;
int x=15; 0804a020 <x>:
int y; 804a020: 0f 00 00 00

int a() {
return *ep+x+y;
}
Merging Re-locatable Object Files
into an Executable Object File
Re-locatable Object Files Executable Object File

system code .text


0
system data .data
headers
system code .text
main()
main() .text
m.o
int e = 7 .data a()
system data
int e = 7 .data
a() .text int *ep = &e
int x = 15
a.o int *ep = &e .data uninitialized data .bss
int x = 15 .symtab
int y .bss
.debug
Linker and Loader
• Object files and executable files typically have standard formats that
include the compiled machine code and a symbol table containing
metadata about functions and variables that are referenced in the
program.
• For UNIX and Linux systems this standard format is known as ELF (for
Executable and Linkable Format).
• Windows systems use the Portable Executable (PE) format
• macOS uses the Mach-O format.
Different binary file formats are the main reason behind applications
are operating-system specific.
Structures of OS
• Monolithic:
o A monolithic operating
system has no structure all
functionality is provided in a
single static binary file that
runs in a single address
space.
o such systems are difficult to
modify
o primary benefit is efficiency
Layered approach
• A layered operating system is divided into a
number of discrete layers
• where the bottom layer is the hardware
interface and the highest layer is the user
interface.
• Layered software systems have had some
success in fast modification
• It is not ideal for designing operating
systems due to performance problems
microkernel approach
• The microkernel approach for designing operating systems uses a
minimal kernel; most services run as user-level applications.
Communication takes place via message passing
Hybrid Approach
• A modular approach for designing operating systems provides operating
system services through modules that can be loaded and removed
during run time. Many contemporary operating systems are constructed
as hybrid systems using a combination of a monolithic kernel and
modules.
Booting a Computer
• System Firmware
• BIOS (Basic Input Output System)
• UEFI (Unified Extensible Firmware Interface)
BIOS:
CPU->Reset Vector->BIOS->Initialized Resources->Boot Selection->In Boot
device first sector is MBR->Partition table File system->Active Partition have
Secondary Boot loader->OS info-> BIOS to get devices data->Check drivers-
>Kernal Load->GUI
UEFI:
No MBR have GPT (GUID Partition Table)-> File Systems and Partition->All
required thing used in Booting-> OS Selection
Little discussion about Research
• Systematic way of Identifying a Problem
• Formulating a Hypothesis
• Writing Objectives
• Defining Methodology
• Gathering Data
• Interpretation of Results
• Drawing Conclusions
• Proposing Solutions
• EVIDENCE BASED

You might also like