SlideShare a Scribd company logo
Operating System Architectures - Unix
Beuth Hochschule

Summer Term 2014
Operating Systems I PT / FF 2014
Modern UNIX Systems
• System V Release 4 (SVR4) was a major milestone

• AT&T and Sun Microsystems (R.I.P.) combined so-far diverging Unix flavors

• Intention to provide uniform platform for commercial UNIX deployment

• Added preemptive kernel, virtual memory concepts, virtual file system support

• Solaris is the successor of Sun‘s SVR4-based UNIX release

• 4.4BSD was the final version from Berkeley university

• Meanwhile many successful derivatives, including Mac OS X

• Most modern UNIX kernels are monolithic

• All functional components of the kernel have access to all data and methods

• Loadable modules (object files) that can be linked to / unlinked from the kernel at
runtime, stackable
2
Operating Systems I PT / FF 2014
System Programming in Unix
• Unix system interface is a mixture of C library, POSIX, and custom functions

• Linux

• POSIX 1003.1 (mostly) + Standard C library + SVR4 + BSD functions

• Every system call has a platform-dependent symbolic constant

(asm-<arch>/unistd.h) and a symbolic name

• Classes: Process management, time-related functions, signal processing,
scheduling, kernel modules, file system, memory management, IPC, network,
monitoring, security

• MacOS X
• BSD portion derived from FreeBSD (4.4BSD) + Standard C library + ObjC specials

• Free BSD
• POSIX 1003.1 (mostly) + Standard C library + BSD functions
3
Operating Systems I PT / FF 2014
Unix: Everything Is A File
• „The UNIX Time-Sharing System“ - D. M. Ritchie and K. Thompson, 1974

4
Operating Systems I PT / FF 2014
Unix: Everything Is A File
• Hierarchical namespace of special files, ordinary files and directories

• Support for mountable sub trees in one hierarchy

• Today typically de-named as Virtual File System (VFS) concept

• Each supported I/O device is associated with at least one special file in /dev

• Read and written as ordinary files, but leads to device interaction

• Protection relies on filesystem mechanisms

• „Everything can have a file descriptor“ is a better description than 

„Everything is a file“ [Brown2007]

• /proc

• Special file system mounted by the kernel at boot time (since SVR4 / BSD) 

• Representation of kernel information as files, possibility for user - kernel mode
interaction (e.g. ps tool)
5
Operating Systems I PT / FF 2014
Linux
• Unix variant initially targeting the IBM PC, meanwhile broad adoption

• Wide number of supported platforms, source code available as ,free‘ software

• „Free as in speech, not as in beer“ [FSF]

• Monolithic kernel compiled per platform

• /linux/arch/* directory in the source code tree

• Kernel is extensible at run-time by loadable kernel modules (LKM)

• API / ABI for such modules is not stable - module binaries must fit to the kernel
version being executed

• Support for versioning of kernel modules and ,tainting‘ of non-GPL drivers

• Graphic system traditionally completely in user mode
6
Operating Systems I PT / FF 2014
Linux Kernel Components
7
Operating Systems I PT / FF 2014
Linux
8
Operating Systems I PT / FF 2014
Anatomy of a Linux System Call [Mauerer]
• Handler implementations in portable C code („sys_“ prefix) spread in the sources

• Example: sys_getuid(void) in kernel/timer.c

• Kernel code performs mode switch and conversion of function parameters

• Processor registers store system call parameters and system call number

(architecture-specific assembler code)

• errno.h and errno-base.h define positive error return codes, 

delivered as negative number to indicate that this is a problem
9
Application libc Kernel Kernel
Handler
•$0x80 call gate (IA32)
• SYSENTER / SYSEXIT 

(>IA32 PII)
• call_pal PAL_callsys (Alpha)
• sc (PowerPC)
• syscall (AMD64)
Operating Systems I PT / FF 2014
Anatomy of a Linux System Call
• strace tool, based on
ptrace system call

• Interception on
system call boundary

• Access to process
address space
possible

• Hardware-supported
breakpoints possible

• MacOS X: dtruss

• Solaris: truss
10
troeger@dfw:~$ strace -f -T pwd
execve("/bin/pwd", ["pwd"], [/* 14 vars */]) = 0 <0.000279>
brk(0) = 0x80d5000 <0.000012>
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000018>
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7761000 <0.000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) <0.000015>
open("/etc/ld.so.cache", O_RDONLY) = 3 <0.000016>
fstat64(3, {st_mode=S_IFREG|0644, st_size=48165, ...}) = 0 <0.000012>
mmap2(NULL, 48165, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7755000 <0.000014>
close(3) = 0 <0.000011>
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000015>
open("/lib/i686/cmov/libc.so.6", O_RDONLY) = 3 <0.000019>
read(3, "177ELF111000000000303010000n10004000"..., 512) = 512 <0.0
fstat64(3, {st_mode=S_IFREG|0755, st_size=1327556, ...}) = 0 <0.000012>
mmap2(NULL, 1337704, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb760e000 <0.00
mprotect(0xb774e000, 4096, PROT_NONE) = 0 <0.000017>
mmap2(0xb774f000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x140)
mmap2(0xb7752000, 10600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) =
close(3) = 0 <0.000012>
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb760d000 <0.000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb760d8d0, limit:1048575, seg_32bit:1, cont
seg_not_present:0, useable:1}) = 0 <0.000012>
mprotect(0xb774f000, 8192, PROT_READ) = 0 <0.000015>
mprotect(0xb777f000, 4096, PROT_READ) = 0 <0.000014>
munmap(0xb7755000, 48165) = 0 <0.000018>
brk(0) = 0x80d5000 <0.000011>
brk(0x80f6000) = 0x80f6000 <0.000012>
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3 <0.000023>
fstat64(3, {st_mode=S_IFREG|0644, st_size=108793664, ...}) = 0 <0.000011>
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb740d000 <0.000014>
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 3, 0xf37) = 0xb7760000 <0.000014>
close(3) = 0 <0.000012>
getcwd("/net/pao/export/home/staff/troeger", 4096) = 35 <0.000016>
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0 <0.000011>
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb775f000 <0.000
write(1, "/net/pao/export/home/staff/troeg"..., 35/net/pao/export/home/staff/troeger
) = 35 <0.000016>
close(1) = 0 <0.000011>
munmap(0xb775f000, 4096) = 0 <0.000016>
close(2) = 0 <0.000011>
exit_group(0) = ?
Operating Systems I PT / FF 2014
Linux Modules
• Support for dynamically loaded and linked binary kernel parts - modules

• Reduces size of the compiled monolithic kernel binary

• Allows driver integration without re-compilation of the kernel

• Also solves some GPL licensing issues with modern hardware drivers

• Modules are relocatable object files that are linked into the kernel 

• Kernel has table of registered functions with their address (/proc/kallsyms)

• Dynamic linker (ld.so) can load and re-locate the code accordingly (more later)

• modprobe tool, relies on insmod tool which uses the init_module system call
• Considers module dependencies determined by depmod utility (modules.dep)
• Kernel can trigger kmod daemon to automatically load missing module

(request_module)
11
Operating Systems I PT / FF 2014
Linux Modules
12
Operating Systems I PT / FF 2014
Linux Modules
• Versioning

• (Binary) drivers have problems
with updated kernel versions

• Optional solution is to generate
signature checksums for kernel
functions (genksym)

• Module compilation stores
checksums of all used functions
in the implementation

• Kernel may become „tainted“ if
module uses symbol without
demanding a specific version
13
Operating Systems I PT / FF 2014
Mac OS X / Darwin
• Mac OS X kernel is Darwin

• Kernel environment derived from

FreeBSD + Mach

• Available as open source

• Mach components: Low-level functionality

(IPC, SMP, virtual memory, paging, modularity)

• I/O Kit: Framework for simplified driver development

• Network Kernel Extensions (NKE)

• Add / remove kernel modules for 

networking without interruption or

re-compilation
14
(C) developer.apple.com
Operating Systems I PT / FF 2014
Mac OS X / Darwin
• Switch between kernel and user mode is called boundary crossing

• Darwin supports several methods

• Mach IPC / RPC: low-level, low-latency, low bandwidth

• Mach Interface Generator (MIG) implements C API from interface description

• RPC routines are grouped in subsystems (e.g. virtual memory)

• BSD syscall: not pluggable, only intended for filesystem and networking

• BSD sysctl / sysctlbyname: supersedes the syscall interface, pluggable

• Typically used to read / write kernel variables

• BSD ioctl: sends commands directly to device drivers (/dev)

• Classical mechanism from BSD
15
Operating Systems I PT / FF 2014
Summary
16
• Modern operating system tackle three major tasks

• Hide complexity and heterogeneity of the underlying hardware

• Manage system resources

• Ensure flexibility, portability and security through layering

• Fundamental concepts are processes and virtual memory

• All operating systems use ring protection support from hardware to implement user
mode and kernel mode

• Applications use system API to access kernel-mode functionality

• Operating systems have pluggability support for their hardware device drivers

• All operating systems have common roots in history

More Related Content

PDF
Operating Systems 1 (3/12) - Architectures
PDF
Operating Systems 1 (2/12) - Hardware Basics
PDF
Operating Systems 1 (6/12) - Processes
PPT
Windows Kernel-
PPT
Lecture5
PPT
Windows kernel
PPT
Processes Control Block (Operating System)
PPTX
Processes and operating systems
Operating Systems 1 (3/12) - Architectures
Operating Systems 1 (2/12) - Hardware Basics
Operating Systems 1 (6/12) - Processes
Windows Kernel-
Lecture5
Windows kernel
Processes Control Block (Operating System)
Processes and operating systems

What's hot (18)

PPT
Kernal
PPT
Opearating System
PPT
Chapter02
PPT
PPTX
Bca i-fundamental of computer-u-3-functions operating systems
PPT
Process management
PPT
Introduction to OS.
PPTX
Operating System Introduction - Definition, Working, Components
PDF
CS6401 Operating Systems
PPT
5. spooling and buffering
PPTX
Real time operating system
PDF
1 introduction
PDF
Operating System / System Operasi
PDF
Lect01
PPT
OS Components and Structure
PPT
Chapter 22 - Windows XP
PPTX
Nt introduction(os)
Kernal
Opearating System
Chapter02
Bca i-fundamental of computer-u-3-functions operating systems
Process management
Introduction to OS.
Operating System Introduction - Definition, Working, Components
CS6401 Operating Systems
5. spooling and buffering
Real time operating system
1 introduction
Operating System / System Operasi
Lect01
OS Components and Structure
Chapter 22 - Windows XP
Nt introduction(os)
Ad

Similar to Operating Systems 1 (5/12) - Architectures (Unix) (20)

PPT
Basic Linux Internals
PDF
Inside the Mac OS X Kernel
PPT
Introduction to Linux Kernel by Quontra Solutions
PDF
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
PPT
LINUX Device Drivers
PDF
L03SystemCalls.pdf all about system call in os
PDF
Arm device tree and linux device drivers
PPTX
Lec 10-linux-review
PPTX
System calls in operating sytems incluses operating sytem process
PDF
The linux kernel hidden inside windows 10
PPT
Mac Memory Analysis with Volatility
PDF
Operating Systems 1 (4/12) - Architectures (Windows)
PDF
Identifying and Supporting 'X-compatible' Hardware Blocks
PPTX
Lect 1_Embedded Linux Embedded RTOS ppt
PDF
BKK16-103 OpenCSD - Open for Business!
PPTX
Char Drivers And Debugging Techniques
PDF
CNIT 127 14: Protection Mechanisms
PPTX
Device Drivers
PDF
Android memory analysis Debug slides.pdf
PPTX
bfarm-v2
Basic Linux Internals
Inside the Mac OS X Kernel
Introduction to Linux Kernel by Quontra Solutions
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
LINUX Device Drivers
L03SystemCalls.pdf all about system call in os
Arm device tree and linux device drivers
Lec 10-linux-review
System calls in operating sytems incluses operating sytem process
The linux kernel hidden inside windows 10
Mac Memory Analysis with Volatility
Operating Systems 1 (4/12) - Architectures (Windows)
Identifying and Supporting 'X-compatible' Hardware Blocks
Lect 1_Embedded Linux Embedded RTOS ppt
BKK16-103 OpenCSD - Open for Business!
Char Drivers And Debugging Techniques
CNIT 127 14: Protection Mechanisms
Device Drivers
Android memory analysis Debug slides.pdf
bfarm-v2
Ad

More from Peter Tröger (20)

PDF
WannaCry - An OS course perspective
PDF
Cloud Standards and Virtualization
PDF
Distributed Resource Management Application API (DRMAA) Version 2
PDF
OpenSubmit - How to grade 1200 code submissions
PDF
Design of Software for Embedded Systems
PDF
Humans should not write XML.
PDF
What activates a bug? A refinement of the Laprie terminology model.
PDF
Dependable Systems - Summary (16/16)
PDF
Dependable Systems - Hardware Dependability with Redundancy (14/16)
PDF
Dependable Systems - System Dependability Evaluation (8/16)
PDF
Dependable Systems - Structure-Based Dependabiilty Modeling (6/16)
PDF
Dependable Systems -Software Dependability (15/16)
PDF
Dependable Systems -Reliability Prediction (9/16)
PDF
Dependable Systems -Fault Tolerance Patterns (4/16)
PDF
Dependable Systems - Introduction (1/16)
PDF
Dependable Systems -Dependability Means (3/16)
PDF
Dependable Systems - Hardware Dependability with Diagnosis (13/16)
PDF
Dependable Systems -Dependability Attributes (5/16)
PDF
Dependable Systems -Dependability Threats (2/16)
PDF
Verteilte Software-Systeme im Kontext von Industrie 4.0
WannaCry - An OS course perspective
Cloud Standards and Virtualization
Distributed Resource Management Application API (DRMAA) Version 2
OpenSubmit - How to grade 1200 code submissions
Design of Software for Embedded Systems
Humans should not write XML.
What activates a bug? A refinement of the Laprie terminology model.
Dependable Systems - Summary (16/16)
Dependable Systems - Hardware Dependability with Redundancy (14/16)
Dependable Systems - System Dependability Evaluation (8/16)
Dependable Systems - Structure-Based Dependabiilty Modeling (6/16)
Dependable Systems -Software Dependability (15/16)
Dependable Systems -Reliability Prediction (9/16)
Dependable Systems -Fault Tolerance Patterns (4/16)
Dependable Systems - Introduction (1/16)
Dependable Systems -Dependability Means (3/16)
Dependable Systems - Hardware Dependability with Diagnosis (13/16)
Dependable Systems -Dependability Attributes (5/16)
Dependable Systems -Dependability Threats (2/16)
Verteilte Software-Systeme im Kontext von Industrie 4.0

Recently uploaded (20)

PDF
Anesthesia in Laparoscopic Surgery in India
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Business Ethics Teaching Materials for college
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
Anesthesia in Laparoscopic Surgery in India
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
O7-L3 Supply Chain Operations - ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Introduction and Scope of Bichemistry.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O5-L3 Freight Transport Ops (International) V1.pdf
Business Ethics Teaching Materials for college
Open Quiz Monsoon Mind Game Prelims.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
01-Introduction-to-Information-Management.pdf
Pharma ospi slides which help in ospi learning
The Final Stretch: How to Release a Game and Not Die in the Process.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra

Operating Systems 1 (5/12) - Architectures (Unix)

  • 1. Operating System Architectures - Unix Beuth Hochschule Summer Term 2014
  • 2. Operating Systems I PT / FF 2014 Modern UNIX Systems • System V Release 4 (SVR4) was a major milestone • AT&T and Sun Microsystems (R.I.P.) combined so-far diverging Unix flavors • Intention to provide uniform platform for commercial UNIX deployment • Added preemptive kernel, virtual memory concepts, virtual file system support • Solaris is the successor of Sun‘s SVR4-based UNIX release • 4.4BSD was the final version from Berkeley university • Meanwhile many successful derivatives, including Mac OS X • Most modern UNIX kernels are monolithic • All functional components of the kernel have access to all data and methods • Loadable modules (object files) that can be linked to / unlinked from the kernel at runtime, stackable 2
  • 3. Operating Systems I PT / FF 2014 System Programming in Unix • Unix system interface is a mixture of C library, POSIX, and custom functions • Linux • POSIX 1003.1 (mostly) + Standard C library + SVR4 + BSD functions • Every system call has a platform-dependent symbolic constant
 (asm-<arch>/unistd.h) and a symbolic name • Classes: Process management, time-related functions, signal processing, scheduling, kernel modules, file system, memory management, IPC, network, monitoring, security • MacOS X • BSD portion derived from FreeBSD (4.4BSD) + Standard C library + ObjC specials • Free BSD • POSIX 1003.1 (mostly) + Standard C library + BSD functions 3
  • 4. Operating Systems I PT / FF 2014 Unix: Everything Is A File • „The UNIX Time-Sharing System“ - D. M. Ritchie and K. Thompson, 1974
 4
  • 5. Operating Systems I PT / FF 2014 Unix: Everything Is A File • Hierarchical namespace of special files, ordinary files and directories • Support for mountable sub trees in one hierarchy • Today typically de-named as Virtual File System (VFS) concept • Each supported I/O device is associated with at least one special file in /dev • Read and written as ordinary files, but leads to device interaction • Protection relies on filesystem mechanisms • „Everything can have a file descriptor“ is a better description than 
 „Everything is a file“ [Brown2007] • /proc • Special file system mounted by the kernel at boot time (since SVR4 / BSD) • Representation of kernel information as files, possibility for user - kernel mode interaction (e.g. ps tool) 5
  • 6. Operating Systems I PT / FF 2014 Linux • Unix variant initially targeting the IBM PC, meanwhile broad adoption • Wide number of supported platforms, source code available as ,free‘ software • „Free as in speech, not as in beer“ [FSF] • Monolithic kernel compiled per platform • /linux/arch/* directory in the source code tree • Kernel is extensible at run-time by loadable kernel modules (LKM) • API / ABI for such modules is not stable - module binaries must fit to the kernel version being executed • Support for versioning of kernel modules and ,tainting‘ of non-GPL drivers • Graphic system traditionally completely in user mode 6
  • 7. Operating Systems I PT / FF 2014 Linux Kernel Components 7
  • 8. Operating Systems I PT / FF 2014 Linux 8
  • 9. Operating Systems I PT / FF 2014 Anatomy of a Linux System Call [Mauerer] • Handler implementations in portable C code („sys_“ prefix) spread in the sources • Example: sys_getuid(void) in kernel/timer.c • Kernel code performs mode switch and conversion of function parameters • Processor registers store system call parameters and system call number
 (architecture-specific assembler code) • errno.h and errno-base.h define positive error return codes, 
 delivered as negative number to indicate that this is a problem 9 Application libc Kernel Kernel Handler •$0x80 call gate (IA32) • SYSENTER / SYSEXIT 
 (>IA32 PII) • call_pal PAL_callsys (Alpha) • sc (PowerPC) • syscall (AMD64)
  • 10. Operating Systems I PT / FF 2014 Anatomy of a Linux System Call • strace tool, based on ptrace system call • Interception on system call boundary • Access to process address space possible • Hardware-supported breakpoints possible • MacOS X: dtruss • Solaris: truss 10 troeger@dfw:~$ strace -f -T pwd execve("/bin/pwd", ["pwd"], [/* 14 vars */]) = 0 <0.000279> brk(0) = 0x80d5000 <0.000012> access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000018> mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7761000 <0.000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) <0.000015> open("/etc/ld.so.cache", O_RDONLY) = 3 <0.000016> fstat64(3, {st_mode=S_IFREG|0644, st_size=48165, ...}) = 0 <0.000012> mmap2(NULL, 48165, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7755000 <0.000014> close(3) = 0 <0.000011> access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000015> open("/lib/i686/cmov/libc.so.6", O_RDONLY) = 3 <0.000019> read(3, "177ELF111000000000303010000n10004000"..., 512) = 512 <0.0 fstat64(3, {st_mode=S_IFREG|0755, st_size=1327556, ...}) = 0 <0.000012> mmap2(NULL, 1337704, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb760e000 <0.00 mprotect(0xb774e000, 4096, PROT_NONE) = 0 <0.000017> mmap2(0xb774f000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x140) mmap2(0xb7752000, 10600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = close(3) = 0 <0.000012> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb760d000 <0.000 set_thread_area({entry_number:-1 -> 6, base_addr:0xb760d8d0, limit:1048575, seg_32bit:1, cont seg_not_present:0, useable:1}) = 0 <0.000012> mprotect(0xb774f000, 8192, PROT_READ) = 0 <0.000015> mprotect(0xb777f000, 4096, PROT_READ) = 0 <0.000014> munmap(0xb7755000, 48165) = 0 <0.000018> brk(0) = 0x80d5000 <0.000011> brk(0x80f6000) = 0x80f6000 <0.000012> open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3 <0.000023> fstat64(3, {st_mode=S_IFREG|0644, st_size=108793664, ...}) = 0 <0.000011> mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb740d000 <0.000014> mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 3, 0xf37) = 0xb7760000 <0.000014> close(3) = 0 <0.000012> getcwd("/net/pao/export/home/staff/troeger", 4096) = 35 <0.000016> fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0 <0.000011> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb775f000 <0.000 write(1, "/net/pao/export/home/staff/troeg"..., 35/net/pao/export/home/staff/troeger ) = 35 <0.000016> close(1) = 0 <0.000011> munmap(0xb775f000, 4096) = 0 <0.000016> close(2) = 0 <0.000011> exit_group(0) = ?
  • 11. Operating Systems I PT / FF 2014 Linux Modules • Support for dynamically loaded and linked binary kernel parts - modules • Reduces size of the compiled monolithic kernel binary • Allows driver integration without re-compilation of the kernel • Also solves some GPL licensing issues with modern hardware drivers • Modules are relocatable object files that are linked into the kernel • Kernel has table of registered functions with their address (/proc/kallsyms) • Dynamic linker (ld.so) can load and re-locate the code accordingly (more later) • modprobe tool, relies on insmod tool which uses the init_module system call • Considers module dependencies determined by depmod utility (modules.dep) • Kernel can trigger kmod daemon to automatically load missing module
 (request_module) 11
  • 12. Operating Systems I PT / FF 2014 Linux Modules 12
  • 13. Operating Systems I PT / FF 2014 Linux Modules • Versioning • (Binary) drivers have problems with updated kernel versions • Optional solution is to generate signature checksums for kernel functions (genksym) • Module compilation stores checksums of all used functions in the implementation • Kernel may become „tainted“ if module uses symbol without demanding a specific version 13
  • 14. Operating Systems I PT / FF 2014 Mac OS X / Darwin • Mac OS X kernel is Darwin • Kernel environment derived from
 FreeBSD + Mach • Available as open source • Mach components: Low-level functionality
 (IPC, SMP, virtual memory, paging, modularity) • I/O Kit: Framework for simplified driver development • Network Kernel Extensions (NKE) • Add / remove kernel modules for 
 networking without interruption or
 re-compilation 14 (C) developer.apple.com
  • 15. Operating Systems I PT / FF 2014 Mac OS X / Darwin • Switch between kernel and user mode is called boundary crossing • Darwin supports several methods • Mach IPC / RPC: low-level, low-latency, low bandwidth • Mach Interface Generator (MIG) implements C API from interface description • RPC routines are grouped in subsystems (e.g. virtual memory) • BSD syscall: not pluggable, only intended for filesystem and networking • BSD sysctl / sysctlbyname: supersedes the syscall interface, pluggable • Typically used to read / write kernel variables • BSD ioctl: sends commands directly to device drivers (/dev) • Classical mechanism from BSD 15
  • 16. Operating Systems I PT / FF 2014 Summary 16 • Modern operating system tackle three major tasks • Hide complexity and heterogeneity of the underlying hardware • Manage system resources • Ensure flexibility, portability and security through layering • Fundamental concepts are processes and virtual memory • All operating systems use ring protection support from hardware to implement user mode and kernel mode • Applications use system API to access kernel-mode functionality • Operating systems have pluggability support for their hardware device drivers • All operating systems have common roots in history