Duplicate
Export
Register
😥
CS340-Chapter#2
1 Flashcard Deck
Send to Chat
AI Edit
Heading 3
Highlight
Here's your flashcard deck!
Send to Chat
AI Edit
Normal Text
Highlight
You can edit it by clicking the 'edit'! Once you have a few cards, you can begin to study it in full screen or use our AI study mode!
Flashcard Deck
Study
Program execution
The operating system gives users the ability to run applications and programs.
I/O operations
The applications and programs run by users require input and produce output, the operating system provides the environment for this.
File systems
Users and their software can create, delete, read, modify, rename, search, list, share, and protect files and directories, the operating system provides support for all of this.
Protection and security
Users need control over who can access their data, the operating system provides security and protection for files and executing programs.
Error detection and recovery
The operating system provides services for detecting and recovering from errors, such as when files get corrupted or programs crash.
Accounting
The operating system performs accounting to monitor disk usage, memory usage, networking traffic, and other system resources.
Resource management
The operating system manages resources, such as prioritizing certain programs or restricting access to certain file systems.
What is a command-line interface (CLI)?
A type of user interface where a user enters a command by entering plain text followed by a newline character.
What is a command-line interpreter?
A stand-alone program that can be used to interact with the operating system.
What is a shell?
In UNIX, a command line interpreter is called a shell. It is not just a command line interpreter, but a full-fledged programming language.
What is a text terminal?
A terminal that transmits data one character at a time and can only display characters.
How are commands in a CLI executed?
Commands in a CLI can be executed in either of two ways: as a built-in command within the shell or as a system program in a separate executable file.
What is a built-in command?
A built-in command is a command that is implemented within the shell itself.
Give an example of a built-in command in bash.
An example of a built-in command in bash is the 'cd' command.
Give an example of a built-in command in bash.
An example of a built-in command in bash is the 'read' command.
What is a system program?
A system program is a command that is implemented in a separate, executable file.
Give an example of a system program in Linux systems.
An example of a system program in Linux systems is the 'grep' command, which is located in the file '/bin/grep'.
Give an example of a system program in Linux systems.
An example of a system program in Linux systems is the 'date' command, which is located in the file '/bin/date'.
Are there commands that can be implemented both as a built-in command and as a system program?
Yes, there are commands that can be implemented both as a built-in command and as a system program.
Give examples of commands that can be implemented both as a built-in command and as a system program.
Examples of commands that can be implemented both as a built-in command and as a system program are 'echo', 'kill', and 'pwd'.
What is a system call?
A call to code inside the kernel of the operating system made via a software interrupt or trap.
What is the purpose of a system call?
To allow a user process to explicitly request a service from the kernel.
Do user programs directly invoke system calls?
No, user programs typically call wrapper functions that invoke system calls.
What is a wrapper function?
A function whose only purpose is to make a call to another function, often a system call.
Where does the wrapper function run?
In user mode as part of a user level library.
Where does the actual system call run?
In kernel mode inside the operating system's kernel.
What is an API?
An Application Programming Interface (API) is a definition or collection of definitions that specify how a program is to obtain the services provided by some other piece of software.
What is the API in the context of operating systems and the kernel?
In the context of operating systems and the kernel, an API is the set of specifications of functions for obtaining the services of the kernel.
Why do programming languages provide wrapper functions for system calls?
Programming language libraries usually provide wrapper functions for system calls to allow programs written in that language to obtain kernel services.
What is an example of a programming language library that contains wrapper functions for system calls in GNU Linux?
The GNU C library, glibc, contains wrapper functions for all of the system calls in GNU Linux.
What are the three most common APIs mentioned in the text?
The three most common APIs mentioned are the WinAPI for Windows, POSIX API for POSIX-based systems (including UNIX, Linux, and macOS), and Lava API for the Lava virtual machine (IVM).
Function that program calls to obtain services from the kernel
Wrapper function in the API
Function that program calls to obtain services from the kernel
Not a system call, but the wrapper function defined in the API
System call
The actual system call invoked within the wrapper itself
String 'SYSCALL'
Placeholder for the code that would switch to kernel mode and jump to the system call handler
When we say that a program calls a system call
It means that the program calls the corresponding wrapper function in the user-level library
When a trap occurs as a result of a system call, what happens?
The mode bit is switched to kernel mode and a system call handler runs.
How does the system call handler know which system call to invoke?
Each system call has a number associated with it, which is read from a register (e.g., in Linux it is in the eax register).
What does the system call dispatch table contain?
The address of the start of each system call in the kernel.
What does the system-call handler do?
It invokes the actual kernel function, which runs in kernel mode. When the kernel function is finished, control is returned back to the handler.
When a program makes a call to a system call function like `read(fd, buffer, 256)`, how are the arguments of this function made available to the kernel?
The arguments are passed to the kernel via registers or the stack, depending on the specific calling convention used.
Register Method
The simplest method for passing arguments of system calls is to put them into known registers in a specific order.
Block Method
In the block method, the parameters are stored in a block of consecutive bytes in memory and the address of the block is passed in a register.
Stack Method
In the stack method, the parameters are pushed onto the stack by the program and popped off the stack by the kernel.
Limitations of Register Method
The register method may not work when the number of parameters exceeds the number of available registers or if the lengths of these parameters exceed the size of the registers.
Limitations of Stack Method
The stack method is usually slower because there are separate stacks for the user program and the kernel, and popping from one and pushing to the other is time-consuming.
Combination of Register Method and Block Method in Linux
Linux uses a combination of the register method and the block method. If the parameters fit into the registers, it uses them; otherwise, it uses the block method.
Parameter Limit in Linux System Calls
In the current version of Linux, no more than six parameters are allowed for a system call.
System programs
Programs shipped or downloaded when the operating system is installed and can only be invoked as commands on the command line.
Application
A program that can be run from the command line but is not a system program.
Fuzzy distinction
The distinction between an application and a system program is not clearly defined and can be subjective.
System Programs
Programs that extend the functionality of the operating system and make it convenient to develop software on the system.
Applications
Word processors, game programs, spreadsheets, web browsers, and integrated development environments.
Shell programs
Programs that provide a command-line interface for interacting with the operating system.
Linkers and loaders
Programs that handle the process of linking together multiple object files and loading them into memory to create an executable program.
File manipulation commands
Commands that allow you to manipulate files, such as copying, renaming, deleting, etc.
Process management commands
Commands that allow you to check the status of running processes, terminate rogue processes, etc.
Memory management commands
Commands that allow you to check for memory leaks and manage memory allocation.
File and directory manipulation
Creation, deletion, modification, printing, renaming, copying, checking and changing attributes
Status information
Obtaining system information such as time, date (date), resource utilization (memusage), process status (ps), device status
Software development
Compilers (gcc), linkers (1d), assemblers (as), interpreters and shells (bash), debuggers (gdb), tracers, profilers, version control, etc.
Program loading and execution
Absolute loaders, relocatable loaders, dynamic linker/loaders (1d-linux), object dumpers (objdump), system call tracers (strace), library call tracers (ltrace), etc.
Communication and network services
Remote logins (ssh), communicating with servers (curl), remote file transfer (sftp, scp), send messages to a screen (write)
Background services
Services that run in the background include ssh daemons (sshd), printer daemons (lpd, cupsd), various other network daemons, and so on. They are started up at boot time and usually remain running until shutdown.
What are program development tools?
Program development tools are software tools used for program development, such as editors, pre-processors, compilers, linkers, debuggers, profilers, and dynamic linker/loaders.
Why do we single out program development tools?
Program development tools were initially targeted towards making program development environments more productive. Understanding these tools helps in understanding the design decisions of operating systems.
What are some examples of program development tools?
Some examples of program development tools include editors, pre-processors, compilers, linkers, debuggers, profilers, and dynamic linker/loaders.
Why is it important to understand the steps involved in turning source code into a running process?
Understanding the steps involved in program execution helps in understanding the reasons behind design decisions in operating systems.
Software library
A file containing compiled code and possibly data that can be used by other programs.
Stand-alone executable
An executable program that can be run independently without any additional files or libraries.
Functions
Reusable blocks of code that perform a specific task.
Type definitions
Specifications of the data type and its characteristics.
Constants
Fixed values that do not change during program execution.
C standard I/O library
A library in the C programming language that provides functions for input and output operations.
C++ iostreams library
A library in the C++ programming language that provides objects and functions for input and output operations.
Loader
A program that loads a binary executable file into memory.
Relocatable code
Code that can be loaded at different memory locations and still execute correctly.
Static linking
The process of combining libraries into the program executable by the linker when creating the executable.
Dynamic linking
The process of linking libraries at run-time, where the libraries are loaded into memory when needed.
Static libraries
Libraries with the extension '.a' that are used for static linking.
Dynamic libraries
Libraries with the extension '.so' (shared objects) that are used for dynamic linking.
gcc -o myprog main.o utilities.o mathstuff.o io.o -lm
A command to compile and link a program named 'myprog', including the object files 'main.o', 'utilities.o', 'mathstuff.o', 'io.o', and the math library '-lm'.
Why is dynamic linking preferred?
Dynamic linking is preferred because it allows for better use of memory and faster load times. It also eliminates the need for recompilation or rebinding when libraries change.
Why does the UNIX world call dynamically linkable libraries 'shared objects'?
The UNIX world calls dynamically linkable libraries 'shared objects' because they can be designed to be shareable, meaning only one copy is needed in memory.
What are the advantages of dynamic linking?
The advantages of dynamic linking include faster load times, better use of memory, and the ability to avoid recompilation or rebinding when libraries change.
Advantages of Static Linking
1. Portability: Executables whose libraries are all statically linked can be run on any machine with the same architecture without requiring the presence of the exact library they were compiled against. 2. Performance: Statically-linked programs are faster as they don't incur the performance cost associated with references to shared library routines. 3. Other minor advantages related to concepts of virtual memory.
Portability
Executables whose libraries are all statically linked can be run on any machine with the same architecture without requiring the presence of the exact library they were compiled against.
Performance
Statically-linked programs are faster as they don't incur the performance cost associated with references to shared library routines.
Other minor advantages
There are other minor advantages related to concepts of virtual memory.
Portability
The ability of an executable to run on multiple platforms.
Binary Format
The format for applications that dictates the layout of the header, instructions, and variables.
ELF
Executable and Linkable Format, the standard format for executable and relocatable files in Linux.
PE
Portable Executable format, used by Windows systems.
Mach. O
Executable format used by macOS.
APIs
Application Programming Interfaces, specify how the source code should be written.
System Calls
Actions performed by an application to request services from the operating system.
Compiler
A program that translates source code into machine code.
Linker
A program that combines multiple object files into a single executable file.
Hardware Platforms
Different computer architectures and systems on which an executable can run.
Solution 1: Compile and link according to an ABI
An ABI defines how the components of the binary code can interface with a given kernel and CPU architecture.
Solution 2: Write code in an interpreted language
Interpreted languages like Python can run slowly compared to compiled languages.
Solution 3: Write code in a language that uses a virtual machine
Languages like Java with a virtual machine (Java Runtime Environment) can result in slower programs.
Solution 4: Manual porting to each operating system
This involves porting the application manually to each operating system, which is time-consuming and needs to be repeated with each new version.
Information hiding
Separating the methods that implement a particular component from the design of that component itself makes system maintenance and modification easier.
Levels or layers of abstraction
System software can be simplified and verified by organizing the functions as a hierarchy that can make only downward calls and upward returns.
Virtual machines
A set of related functions can be implemented as a simulation of a machine whose interface is an 'instruction set' and whose internal structure and data are hidden.
Principle of least privilege
In a particular abstraction layer of a computing environment, every entity (process, user, program, etc.) must have only the privilege needed to access only the information and resources that are necessary for its legitimate purpose.
Principle of locality
Processes use small subsets of their address spaces for extended periods.
Policy
A set of rules that guides and determines decisions
Mechanism
A process, technique, or system for achieving a result
Separation of Policy and Mechanism
A principle in software engineering that states policies should be separate from mechanisms
Flexibility of Mechanisms
Mechanisms should be flexible enough to work with different policies
Windows vs Linux
In Windows, mechanism and policy are tied together, while in Linux, anyone can make changes to mechanisms and propose changes to policies
In what languages are operating systems written?
Early operating systems were written in assembly language. The first operating system to be written exclusively in a high-level language was the Burroughs MCP, in 1961. Others followed in PL1 and other systems languages. UNIX was the first operating system to be implemented in C. Now, most operating systems are written in a mix of assembly and C and/or C++. The kernel is usually written in assembly and C, while the libraries and systems programs are written in C and/or C++. Some systems programs are also written in scripting languages such as Perl, Python, and shell languages such as Bash.
What was the first operating system to be written exclusively in a high-level language?
The Burroughs MCP, in 1961.
What was the first operating system to be implemented in C?
UNIX.
What are the common languages used to write operating systems?
Most operating systems are written in a mix of assembly and C and/or C++. The kernel is usually written in assembly and C, while the libraries and systems programs are written in C and/or C++. Some systems programs are also written in scripting languages such as Perl, Python, and shell languages such as Bash.
What are the advantages and disadvantages of implementing an operating system in a higher-level language?
The main advantage is increased productivity and a higher level of abstraction. However, the drawback is reduced speed, although modern compilers and processors have mitigated this to some extent.
What is the structure of an operating system?
The arrangement and interrelationships among its separate executable modules.
What does the structure of an operating system refer to?
How the binary files are interrelated, not how the source code files are written and organized.
How can the structure of an operating system be implemented?
It can be implemented as a single file with a single address space, multiple files forming layers or rings, or using small files with message passing.
Monolithic Structure
All functionality of the kernel is in a single, static binary file that runs in a single address space.
Early versions of UNIX
Monolithic structure
Early versions of Linux
Monolithic structure
Original UNIX operating system
Monolithic structure
Layered Structure
The operating system is divided into a number of layers, with successively higher layers built upon and dependent upon lower layers.
Ring Structure
The operating system is organized as a set of concentric rings, with outer rings built upon and dependent upon inner rings.
Ring 0
The innermost ring in the ring structure, representing the hardware.
User Interfaces
The outermost ring in the ring structure, representing the set of user interfaces.
Drivers
The intermediate rings in the ring structure, responsible for managing hardware devices.
Kernel
A ring in the ring structure, implementing core operating system functionality.
Multics
An example of a system that used a ring structure as a design principle for protection.
What is the disadvantage of incorporating services into a monolithic kernel?
Modifying them requires careful work to prevent side effects in the kernel, and being able to start and stop services without changes to the state of the kernel requires design changes within the kernel itself. Large kernels are also hard to maintain.
Who created the RC 4000 Multiprogramming System?
Per Brinch Hansen and his team of developers.
What is the concept of a microkernel design?
To make the kernel as small as possible, containing only absolutely essential functionality that needs to run in privileged mode. All other functionality is put into separate programs that run in user mode, communicating through message-passing.
Benefits of Microkernels
Advantages of creating a microkernel with only essential functions and everything else in separate programs.
Easier to extend
Extending a microkernel-based operating system is easier because most of the extension is in separate programs rather than inside the kernel.
Easier to port
Porting the operating system to new architectures is easier with a microkernel because there is less code to modify.
More reliable
A microkernel-based operating system is more reliable because the kernel is smaller, easier to debug, and maintain.
More secure
A microkernel-based operating system is more secure as the smaller kernel is easier to analyze for security flaws and satisfies the principle of least privilege.
What services were included in the earliest microkernels?
inter-process communication system, process scheduling, and memory management
Where were other services like file systems, device drivers, and application interface located in the earliest microkernels?
user-space processes
Who designed and built MINIX?
Andrew S. Tanenbaum
Where is Andrew S. Tanenbaum a professor of computer science?
Vrie Universiteit Amsterdam
Where was MINIX designed and built?
Netherlands
What was the processor MINIX 1.0 designed to run on?
Intel 8088
Which version of Unix was MINIX 1.0 system-call compatible with?
Seventh Edition Unix
Where can the source code of MINIX 1.0 be found?
In Andrew S. Tanenbaum's book, Operating Systems: Design and Implementation
What is the most well-known example of a microkernel-based operating system today?
The Mach kernel
Where was the Mach kernel developed?
Carnegie Mellon University
Which operating system uses the Mach kernel?
macOS
What components are included in the Mach kernel?
IPC mechanism, memory management, and process scheduler
How do user programs interact with the Mach kernel?
Through message passing
What is Redox?
An open source, Unix-based operating system written in Rust
Where can Redox be found?
GitHub
What is sel4?
A formally verified microkernel
Is sel4 open source?
Yes
Which foundation supports sel4?
L4 Foundation
Loadable Kernel Modules
An alternative that offers a compromise between microkernels and monolithic systems is to use loadable kernel modules.
Kernel Size in Loadable Kernel Modules
The idea is to keep the kernel small, but not as small as a microkernel. The kernel provides core services, and the other services are loadable dynamically as needed, while the kernel is running.
Kernel Modules
Other services are provided in kernel modules, which are executable files that can be loaded and linked into the kernel at run-time.
Linux and Loadable Kernel Modules
Linux uses loadable kernel modules for a variety of services, ranging from device drivers to file systems to cryptographic services.
Inserting and Removing Kernel Modules
Kernel modules can be inserted into and removed from the kernel from the command line.
Hybrid Operating Systems
Most operating systems are hybrids of two or more models.
Linux
A monolithic system but it also uses loadable kernel modules.
Windows operating systems
Mostly monolithic but provide support for separate subsystems.
macOS
A complex, partially layered system built on top of the Darwin kernel.
Darwin kernel
The core of macOS, consisting of an open source Mach microkernel and elements of FreeBSD UNIX.
What is the process of starting a computer by loading the kernel called?
Bootstrapping or booting the system
Where does execution start when a machine is powered on?
At a small boot loader in nonvolatile firmware
What are the two types of nonvolatile firmware used in systems?
BIOS (in older systems) and UEFI (in newer systems)
What tests does the boot loader usually run?
Diagnostic tests such as inspecting memory and the CPU, and discovering devices
What is the second boot loader called?
The boot block
What does the program stored in the boot block do?
Loads the kernel into memory
What is the Linux kernel image?
A compressed file that needs to be extracted after it is loaded into memory
What is GRUB?
An open source bootstrap program for Linux and UNIX systems
What can be done using GRUB at boot time?
Changes can be made, such as selecting which kernel to load
What happens after the kernel is loaded?
The bootstrap program transfers control to the kernel.
What happens next after the bootstrap program transfers control to the kernel?
It is kernel-dependent, but most systems will load drivers, start services, and eventually display a user interface.
What does the Linux kernel do after it is loaded?
It loads necessary drivers, switches the root file system, creates the initial process (systemd), and starts servers.
What services may the Linux kernel start after loading?
Web servers, SSH servers, print services, etc.
What is displayed eventually after the Linux kernel loads?
A login prompt.
Send to Chat
AI Edit
Normal Text
Highlight
Continue adding your notes here.
Scholarly Assistant's Insights
Flashcard deck on program execution, I/O operations, file systems, protection, security, error detection, and recovery.
Flashcards
Operating Systems
System Programming
Kernel
Software Development
Ask Scholarly Assistant
Similar Pages
Login to Leave a Comment
Give your feedback, or leave a comment on a page to share your thoughts with the community.
Login