AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Outline
1 Announcements
2 Kernel Types
3 Simple OS Examples
4 System CallsSystem Call OverviewTypes of System Calls – §2.4, SGG
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 1 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Announcements
Week03 labstrace: program to watch system callsC programming tuteICT Learning Centre C programming intro.
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 2 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
The OS Kernel
The kernel is the of an OSIt has complete control over everything that occurs in thesystemKernel overview and comparison
(courtesy of Wikipedia)P. Healy (University of Limerick) CS4023 Autumn 2019–2020 3 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Monolithic Kernel
Older monolithic kernels were written as a mixture ofeverything the OS needed, without much of a structure.The monolithic kernel offers everything the OS needs:
, memory management,multiprogramming, interprocess communication (IPC),
, file systems, network protocols, etc.Newer monolithic kernels have a modular design, whichoffers run-time adding and removal of services. The wholekernel runs in "kernel mode", a processor mode in whichthe software has full control over the machine. Theprocesses running on top of the kernel run in "user mode",in which programs have only access to the kernel servicesModern OS with monolithic kernels: Linux, FreeBSD,NetBSD, Solaris
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 4 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Microkernel
Moves as much from the kernel into “user” space to run asprocessesCommunication takes place between user modules using
BenefitsEasier to extend a microkernelEasier to port the operating system to new architecturesMore reliable (less code is running in kernel mode)More secure
DisadvantagesPerformance overhead of user space to kernel spacecommunication
Example microkernels: L4, Minix, QNX
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 5 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Monolithic vs. Microkernel System Structure
Monolithic Kernel Microkernel
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 6 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Hybrid Kernels
Similar to microkernels, except that they include additionalcode in kernel space so that such code can run moreswiftly than it would were it in user spaceThese kernels represent a compromise that wasimplemented by some developers before it wasdemonstrated that pure microkernels can provide highperformanceHybrid kernels should not be confused with monolithickernels that can load modules after booting (such as Linux)Example OS with hybrid kernels: Microsoft Windows NT,2000 and XP, Windows 7, DragonFly BSD
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 7 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
OS Kernels Comparisons
(courtesy Wikipedia)
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 8 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Modules
Best current methodology for OS design involves usingOOP techniques to create a modular kernelKernel has set of core components and links in additionalservices as required – either at boot time or run timeUses dynamically loadable modules
Solaris and 7 types of loadable modules
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 9 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
Mac OS X Structure
Apple’s Mac OS X uses a hybrid structureTop layers include application environments and servicesproviding a graphical interface to applicationsBelow these layers is kernel environment, which consistsmainly of
Mach microkernel: provides memory management, threadscheduling and support for RPCs and other types of IPCBSD kernel: file system support, networking
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 10 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
MS-DOS
Shell invoked when systembootedSimple method to run program:No separate process createdSingle memory space; fig. (a)Loads program into memory,overwriting all but the kernel; fig.(b)On program exit shell isreloaded; back to (a)
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 11 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
FreeBSD
Unix variantMultitaskingOn user login, invoke user’schoice of shellShell executes fork() systemcall to create process
Executes exec() to loadprogram into processShell waits for process toterminate or continues withuser commands
Process exits with:code = 0: no errorcode > 0: error code
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 12 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Outline
1 Announcements
2 Kernel Types
3 Simple OS Examples
4 System CallsSystem Call OverviewTypes of System Calls – §2.4, SGG
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 13 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Overview
System call: a request made by any arbitrary program tothe OS for which the said program doesnot have required permissions to executeSystem calls are generally available as
instructions and they are usuallylisted in the various manuals used by theassembly-language programmers
Mostly accessed by programs via a high-level ApplicationProgram Interface (API) rather than direct system call useManaged by run-time support library (set of functionsbuilt into libraries included with a compiler)
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 14 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Overview (contd.)
Three most common APIs are:Windows APIPOSIX API for POSIX-based systems (including virtuallyall versions of UNIX, Linux, and Mac OS X)Java API for the Java virtual machine (JVM)
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 15 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Example Use of System Calls
System call sequence to copy the contents of one file toanother file
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 16 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Linux open() Example
The Linux open() function – a function (which uses a systemcall) for opening a file prior to reading / writing
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 17 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Implementing System Calls
Typically, a number associated with each system callSystem-call interface maintains a table indexed accordingto these numbers
The system call interface invokes intended system call inOS kernel and returns status of the system call and anyreturn valuesThe caller (our program) need know nothing about how thesystem call is implemented
Just needs to obey API and understand what OS will do asa result callMost details of OS interface hidden from programmer byAPI
Managed by run-time support library (set of functions builtinto libraries included with compiler)
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 18 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
API – System Call – OS Relationship
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 19 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Standard C Library Example
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 20 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
System Call Parameter Passing
Three general methods used to pass parameters to the OS
Simplest: pass the parameters in registers...but what if there are more parameters than registers?
Parameters stored in a block, or table, in memory, andaddress of block passed as a parameter in a register
Each individual system call knows how to treat the tablecontentsThis approach taken by Linux and Solaris
Parameters placed, or pushed, onto the stack by theprogram and popped off the stack by the operating system
Block and stack methods do not limit the number or lengthof parameters being passed
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 21 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Links to Explore
How to start developing your own OS kernelJava APIPOSIX APIMac OS X API
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 22 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Outline
1 Announcements
2 Kernel Types
3 Simple OS Examples
4 System CallsSystem Call OverviewTypes of System Calls – §2.4, SGG
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 23 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Categories
Process controlFile managementDevice managementInformation maintenanceCommunications
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 24 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Process Control
end, abortload, executecreate process, terminate processget/set process attributeswait for timewait/signal eventallocate and free memory
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 25 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
File Management
create/delete fileopen, closeread, write, repositionget/set file attributes
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 26 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Device Management
request device, release deviceread, write, repositionget/set device attributeslogically attach or detach devices
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 27 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Information Maintenance
get/set time or dateget/set system data
number of current usersamount of free memory(numerous other statistics)
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 28 / 29
AnnouncementsKernel Types
Simple OS ExamplesSystem Calls
System Call OverviewTypes of System Calls – §2.4, SGG
Communication
create, delete communication connectionsend, receive messagestransfer status informationattach or detach remote devices
P. Healy (University of Limerick) CS4023 Autumn 2019–2020 29 / 29
Top Related