Podcast
Questions and Answers
What is the primary purpose of the mode bit used by the CPU?
What is the primary purpose of the mode bit used by the CPU?
- To indicate whether the CPU is currently executing in a multi-threaded environment.
- To track the amount of memory being used by the currently running process.
- To differentiate between kernel mode and user mode operations, controlling privilege levels. (correct)
- To determine the priority of the currently running process in the CPU scheduler.
When a user application requires a privileged action, what mechanism is used to switch the operating system to Kernel Mode?
When a user application requires a privileged action, what mechanism is used to switch the operating system to Kernel Mode?
- A system call (trap or interrupt). (correct)
- A hardware reset signal.
- A direct memory access (DMA) request.
- A user-level context switch.
Which of the following best describes the role of Application Programming Interfaces (APIs) in the context of system calls?
Which of the following best describes the role of Application Programming Interfaces (APIs) in the context of system calls?
- They are independent programs that run in kernel mode to manage system resources.
- They provide a low-level interface for direct manipulation of kernel data structures.
- They provide a simplified library of functions that application programmers can use to access system calls, hiding the details of the O/S interface. (correct)
- They directly expose the underlying hardware architecture to user applications.
In the Windows operating system, where are Windows API functions typically located?
In the Windows operating system, where are Windows API functions typically located?
What is the primary benefit of using an API between normal programs and the operating system?
What is the primary benefit of using an API between normal programs and the operating system?
In Unix-like systems, what is the API that typically sits between normal programs and the operating system?
In Unix-like systems, what is the API that typically sits between normal programs and the operating system?
What occurs when a function call is made in a program?
What occurs when a function call is made in a program?
What is the role of the C standard library functions in programming?
What is the role of the C standard library functions in programming?
What is the primary role of the operating system in handling application requests to access hardware devices?
What is the primary role of the operating system in handling application requests to access hardware devices?
How does a device controller typically signal the CPU upon completion of a task?
How does a device controller typically signal the CPU upon completion of a task?
What information does the interrupt vector provide to the CPU when an interrupt occurs?
What information does the interrupt vector provide to the CPU when an interrupt occurs?
Which of the following events would typically trigger a hardware interrupt?
Which of the following events would typically trigger a hardware interrupt?
What is the key difference between a trap (exception) and a hardware interrupt?
What is the key difference between a trap (exception) and a hardware interrupt?
Which of the following scenarios would most likely result in a software interrupt (trap)?
Which of the following scenarios would most likely result in a software interrupt (trap)?
What is the primary purpose of privilege levels within an operating system?
What is the primary purpose of privilege levels within an operating system?
In the context of operating system privilege levels (protection rings), what is the significance of Ring 0?
In the context of operating system privilege levels (protection rings), what is the significance of Ring 0?
In an operating system employing protection rings, what is the primary security benefit of isolating user applications to Ring 3?
In an operating system employing protection rings, what is the primary security benefit of isolating user applications to Ring 3?
Why do virtualization platforms like VMware place guest kernels in Ring 1 rather than Ring 0?
Why do virtualization platforms like VMware place guest kernels in Ring 1 rather than Ring 0?
When a user application requires a service from the operating system, such as writing to a file, how does it typically request this service?
When a user application requires a service from the operating system, such as writing to a file, how does it typically request this service?
What is the primary purpose of privilege escalation, such as using sudo
in Linux or 'Run as administrator' in Windows?
What is the primary purpose of privilege escalation, such as using sudo
in Linux or 'Run as administrator' in Windows?
Consider a scenario where a user attempts to access a file they do not have permission to read. Which security mechanism is primarily responsible for preventing this unauthorized access?
Consider a scenario where a user attempts to access a file they do not have permission to read. Which security mechanism is primarily responsible for preventing this unauthorized access?
Why is it important for processes to execute within their own assigned address space?
Why is it important for processes to execute within their own assigned address space?
What happens when a program running in user mode (Ring 3) requires access to a hardware resource, such as controlling a printer?
What happens when a program running in user mode (Ring 3) requires access to a hardware resource, such as controlling a printer?
How do operating systems ensure that multiple users can concurrently access system resources without causing conflicts or data corruption?
How do operating systems ensure that multiple users can concurrently access system resources without causing conflicts or data corruption?
What is a primary reason many Linux servers are configured to operate solely with a command-line interface (CLI)?
What is a primary reason many Linux servers are configured to operate solely with a command-line interface (CLI)?
How do external commands differ from built-in commands in a command-line interface (CLI)?
How do external commands differ from built-in commands in a command-line interface (CLI)?
A system administrator needs to manage a Linux server with limited resources using a minimal shell. Which shell would be the most appropriate choice?
A system administrator needs to manage a Linux server with limited resources using a minimal shell. Which shell would be the most appropriate choice?
In a GUI environment, multiple windows from different applications can be displayed at once. What is a key restriction on user interaction in this scenario?
In a GUI environment, multiple windows from different applications can be displayed at once. What is a key restriction on user interaction in this scenario?
Which of the following best describes the role of a touch screen in a mobile operating system?
Which of the following best describes the role of a touch screen in a mobile operating system?
A software developer is creating a cross-platform application that needs to run on both Windows and Linux systems. Which interface type would be available on both platforms?
A software developer is creating a cross-platform application that needs to run on both Windows and Linux systems. Which interface type would be available on both platforms?
A system administrator wants to switch from Command Prompt to a shell in Windows that offers more advanced features and functionalities. Which shell should they choose?
A system administrator wants to switch from Command Prompt to a shell in Windows that offers more advanced features and functionalities. Which shell should they choose?
Which of the following is an example of a desktop environment that relies on X-Windows?
Which of the following is an example of a desktop environment that relies on X-Windows?
When a process transitions to the 'Waiting' state, what is it typically waiting for?
When a process transitions to the 'Waiting' state, what is it typically waiting for?
What is the primary function of the Program Counter (PC) register?
What is the primary function of the Program Counter (PC) register?
Which of the following memory segments is used for storing variables without a default value?
Which of the following memory segments is used for storing variables without a default value?
Why is it necessary to save the contents of registers and the program counter during multitasking?
Why is it necessary to save the contents of registers and the program counter during multitasking?
Which of the following best describes the role of the 'Heap' in process memory management?
Which of the following best describes the role of the 'Heap' in process memory management?
What information is contained within a Process Control Block (PCB)?
What information is contained within a Process Control Block (PCB)?
Which of the following scenarios best illustrates the concept of preemptive multitasking?
Which of the following scenarios best illustrates the concept of preemptive multitasking?
How do Base and Limit registers contribute to memory protection in an operating system?
How do Base and Limit registers contribute to memory protection in an operating system?
A computer has a single CPU. Which of the following is the most accurate description of how it appears to run multiple programs simultaneously?
A computer has a single CPU. Which of the following is the most accurate description of how it appears to run multiple programs simultaneously?
Which of the following statements correctly describes the key difference between multiprocessing and multithreading?
Which of the following statements correctly describes the key difference between multiprocessing and multithreading?
A program is considered a ___, while a process is considered ___.
A program is considered a ___, while a process is considered ___.
An operating system receives an interrupt from a network interface card (NIC). What is the most likely immediate action the OS will take?
An operating system receives an interrupt from a network interface card (NIC). What is the most likely immediate action the OS will take?
How does the stack typically manage memory allocation?
How does the stack typically manage memory allocation?
At what 'Ring level' do command line interfaces typically operate, and what is its significance?
At what 'Ring level' do command line interfaces typically operate, and what is its significance?
What is the primary purpose of multiprogramming in an operating system?
What is the primary purpose of multiprogramming in an operating system?
Consider a scenario where a user is typing in a word processor. Which of the following sequences best describes the chain of events from keystroke to displaying the character on the screen?
Consider a scenario where a user is typing in a word processor. Which of the following sequences best describes the chain of events from keystroke to displaying the character on the screen?
Which statement accurately compares cooperative multitasking with preemptive multitasking?
Which statement accurately compares cooperative multitasking with preemptive multitasking?
What is the role of a device controller in the interaction between an application and a hardware device?
What is the role of a device controller in the interaction between an application and a hardware device?
Why are operating systems typically designed to be interrupt-driven?
Why are operating systems typically designed to be interrupt-driven?
A program is running slowly because it frequently needs to read data from the hard drive. Which technique would be most effective in improving the overall system performance?
A program is running slowly because it frequently needs to read data from the hard drive. Which technique would be most effective in improving the overall system performance?
Flashcards
Multitasking
Multitasking
Executing multiple programs seemingly at the same time by rapidly switching between them.
Multiprogramming
Multiprogramming
Loading multiple programs into memory to increase CPU utilization by switching between them.
Multiprocessing
Multiprocessing
Using multiple CPUs or processor cores to execute instructions simultaneously.
Multithreading
Multithreading
Signup and view all the flashcards
Time slice
Time slice
Signup and view all the flashcards
Pre-emptive multitasking
Pre-emptive multitasking
Signup and view all the flashcards
Interrupt
Interrupt
Signup and view all the flashcards
Hardware Interrupt
Hardware Interrupt
Signup and view all the flashcards
Event-driven
Event-driven
Signup and view all the flashcards
Device controller
Device controller
Signup and view all the flashcards
System Call
System Call
Signup and view all the flashcards
Interrupt Vector
Interrupt Vector
Signup and view all the flashcards
Interrupt Handler
Interrupt Handler
Signup and view all the flashcards
Trap (or Exception)
Trap (or Exception)
Signup and view all the flashcards
Privilege Levels (Protection Rings)
Privilege Levels (Protection Rings)
Signup and view all the flashcards
Ring 0
Ring 0
Signup and view all the flashcards
Ring 1 & 2
Ring 1 & 2
Signup and view all the flashcards
User Mode
User Mode
Signup and view all the flashcards
Kernel Mode
Kernel Mode
Signup and view all the flashcards
Concurrent
Concurrent
Signup and view all the flashcards
Privilege escalation
Privilege escalation
Signup and view all the flashcards
System call function
System call function
Signup and view all the flashcards
Mode Bit
Mode Bit
Signup and view all the flashcards
Application Programming Interface (API)
Application Programming Interface (API)
Signup and view all the flashcards
API Functions
API Functions
Signup and view all the flashcards
DLLs in Windows API
DLLs in Windows API
Signup and view all the flashcards
API Abstraction
API Abstraction
Signup and view all the flashcards
API in Unix-like Systems
API in Unix-like Systems
Signup and view all the flashcards
Function Call
Function Call
Signup and view all the flashcards
Command Line Interface (CLI)
Command Line Interface (CLI)
Signup and view all the flashcards
Built-in Commands
Built-in Commands
Signup and view all the flashcards
External Commands
External Commands
Signup and view all the flashcards
Command Prompt
Command Prompt
Signup and view all the flashcards
PowerShell
PowerShell
Signup and view all the flashcards
Bash (Bourne Again Shell)
Bash (Bourne Again Shell)
Signup and view all the flashcards
Multiple Windows
Multiple Windows
Signup and view all the flashcards
CDE
CDE
Signup and view all the flashcards
Program
Program
Signup and view all the flashcards
Process
Process
Signup and view all the flashcards
Process ID (PID)
Process ID (PID)
Signup and view all the flashcards
Register (CPU)
Register (CPU)
Signup and view all the flashcards
Program Counter
Program Counter
Signup and view all the flashcards
Process Control Block (PCB)
Process Control Block (PCB)
Signup and view all the flashcards
Process state: New
Process state: New
Signup and view all the flashcards
Process state: Running
Process state: Running
Signup and view all the flashcards
Study Notes
CPU Operation
- The CPU can only execute one task at a time
- The CPU's processing speed is much faster than other computer components
- CPU speeds run at multiples of the system bus
- Hard drive read and write operations are very slow compared to CPU cycles
- Methods can increase CPU utilization by organizing jobs for processors when waiting for disk read/writes or other I/O operations
- Keyboard input or video output to monitor are considered input/output operations
- Multiprogramming, multitasking, multiprocessing, and multithreading increase CPU usage
CPU Scheduling
- Multiprogramming increases CPU utilization by loading multiple programs into memory simultaneously
- The OS switches the processor between program jobs to avoid processor idling
- Cooperative multitasking involves one program releasing control so another can run
- Multitasking is a method used on modern OS which runs several programs at the same time
- Multitasking extends multiprogramming and also runs other system tasks
- The CPU assigns time slices to each running process as the system makes it appear that programs run simultaneously
- Multiprocessing involves multiple CPUs on a motherboard, where multiple processor cores exist in the same CPU package
- Multiprocessing directs program instructions to different processors, speeding up the execution of a program
- Multithreading requires multiple processors so that several strings of commands can be directed to different processors to be executed in parallel
Time Sharing (Multitasking)
- The processor switches between multiple jobs by assigning each process or job equal time via a time slice
- Pre-emptive multitasking stops the current process execution and returns to a previous process
- Processes appear to run simultaneously since user interaction is slow
Operating System Interrupts
- Operating systems are interrupt-driven and the OS may execute commands when a packet arrives at the NIC
- An interrupt is sent from the NIC to the CPU along the control bus, these hardware interrupts come from a device controller
- The OS suspends execution of the current process to service the arriving packets
- The OS will sit idle unless it has a process to execute and it waits for an event to initiate action
- A user opening an executable constitutes an "event"
- Most OS actions are triggered by either a hardware or software interrupt
Device Controller
- A device controller manages a specific device
- System calls from the application to the OS occur if an application program executes code that requires interaction with a device
- The OS takes over and issues the appropriate instructions to the CPU, where the CPU then sends commands and data to the device controller by writing to local buffers in the controller
- The device controller has the instruction required to perform the actions requested by the CPU
Hardware Interrupts
- The device controller signals an interrupt to notify the CPU when the requested task is complete, so the CPU stops its current task to service the interrupt
- The value of the interrupt is a pointer to a data structure called the interrupt vector, it points to the memory address of the service routine with instructions to handle the device request
- The service routine with instructions to handle the device request is called an interrupt handler, and the table of interrupt vectors is stored in low memory locations
- The OS then passes the results back to the application program
- A device can issue a hardware interrupt when an event happens, where the interrupt is a request to the OS to service the device
- Pressing a key on the keyboard or when data arrives at the NIC are examples of a the device requesting service from the OS
Software Interrupts
- A trap or exception is a software interrupt from applications or system programs
- Software interrupts requests specific service or action to be performed, such as saving data to disk or sending a document to the printer
- Software interrupts occur when a software error occurs such as division by zero, invalid memory access, or attempts by a program to modify another running program's data
Privileged Levels
- The OS supports multiple privilege levels that protect the system hardware and OS by restricting the CPU instructions that programs at a particular level can use
- In the original model, Ring 0 is the level with the most privileges and interacts directly with the physical hardware like the CPU and memory
- Rings 1 & 2 give privileges to hardware device drivers, and Ring 3 was for user applications
- Programs at ring 3 are not permitted to access hardware at Ring 0
- Most operating systems only supported 2 modes of operation: Ring 0 & Ring 3
User & Kernel Modes
- Windows and Linux use two levels of protection
- User Mode prevents access to system instructions that can damage the hardware, damage the kernel, or gain access to other processes and correlates to Ring 3
- Kernel Mode, also called Privilege Mode, Supervisor Mode, or System Mode, correlates to Ring 0
- Hardware that supports virtualization often use more levels
- Virtual Box and VMware put the guest kernel code in Ring 1 so the Guest OS has more privileges than user applications but not full kernel mode privileges
Protection and Security
- A computer may have multiple users and run multiple processes at the same time, known as "concurrent" execution
- Access to data must be controlled so that only the proper authorized user or process has access to that data
- Processes only execute in their assigned address space, and processes and file permissions are tied to a User ID
- Privilege escalation allows a user to change to an effective ID with more rights, such as "Run as administrator" in Windows," or "sudo" in Linux
System Calls
- Operating systems provide file management and print services
- User applications and system programs access these services via system calls, where a system call is a request by a user program to perform a task reserved for the operating system
- A system call is a programming interface to the operating system with a request to switch from user mode to privileged mode
- Typically, system calls are written in a high-level language like C or C++ whereas calls directed to hardware devices could be written in low level assembly language
- The CPU uses a mode bit to determine the level of privilege
- Kernel Mode is assigned 0 and User Mode is assigned 1
- When a user application starts, the mode bit is set to 1; but when the user application requires a privileged action, it must make a System Call (trap or interrupt) to the OS
- The OS then switches to Kernel Mode (0) and performs the operation
- System calls are programmed directly, and programming language compilers and interpreters include libraries to make using system calls easier, where these libraries a called Application Programming Interfaces (APIs)
- Windows API functions are located in dynamic link libraries (dlls) such as Kernel32dll, User32dll, shell32dll, Gui32.dll
- The details of the O/S interface are hidden from the programmer by the API
- Systems provide a library or API between normal programs and the OS
- On Unix-like systems, the API is part of a C library (libc) implementation
- On Windows NT, the API is part of the Native API, ntdll.dll library
Function Calls
- A function call is loading a piece of code into user space to perform a specific task
- After the task or subroutine is complete, control is passed back to the main program
- The C standard library provides built-in functions available to programs
- A function often does a system call during its execution
Process Management
- A program is a passive entity, a block of instruction code stored on disk
- A process is an active entity which is a program being executed
- Each process is given a process ID (PID)
- Several programs may run at the same time, each as a separate process, such as running a word processor, browsing the Internet, and listening to music
- The assigned memory space is released back to the OS for other processes when a process terminates
- A register is a small memory area built into a CPU, and each process instruction and its related data must be loaded from memory into registers before execution
- The process ID (pid) is a unique number assigned to each process
- A program counter is a special register that indicates the next instruction to be executed, with the contents of the registers and counter saved when a computer is multitasking and switching between active processes
Process Control Block
- Each process has a Process Control Block (PCB)
- The PCB contains information used by the operating system to monitor and manage a process
- On multi-tasking systems processes do not run continuously, so the program counter and register portions of the PCB are used to store values when the processes are not actually running
Process States
- New signals that a process is being created through assigning a Process ID (PID) and memory addresses (stack & heap)
- Running indicates that instructions are being executed by the program counter
- Waiting specifies a process is waiting for some event to occur, like an interrupt
- Ready means a process is waiting to be assigned to a processor via a time slice
- Terminated signals that a process has finished execution
Memory
- The OS assigns a dedicated memory space to each process id (PID) divided as follows
- Code segment (text) consists of binary executable code (read only)
- Initial Data segment consists of assigned variables for the process
- Block Started by Symbol (BSS) consists of variables without a default value
- Heap is assigned as memory allocated for use by process
- Temporary space for functions called by the process is the stack
- Base and Limit registers define the protected memory area addresses for a process
- Each process is allocated dynamic memory addresses called a heap, where storing data is calculated by an instruction
- A process can be allocated dynamic memory space called a stack
- The stack is assigned memory space (buffers) at the highest usable memory location and grows downwards
- The stack holds temporary user input variables into a program such as a number entered into calculator program
Command Line Interface (CLI)
- A CLI is a text mode interface where users interact with programs via a keyboard and screen using only simple text characters often called shells or command interpreters
- The CLI operates at Ring level 3, the outer shell with the kernel in the middle
- The CLI is used for system administration purposes as it is flexible and efficient and available on Windows, Mac OSX and Linux
- CLI commands can be either built into the shell, or external where built-in commands are part of the shell program and always run within the process running the shell
- External commands are separate programs that a shell loads and executes
- Windows shells include the Command Prompt (based on the original MS-DOS shell) and PowerShell (a new shell with much more functionality built into it)
Linux - CLI
- Many Linux servers have CLI only and no GUI for performance and security reasons
- A Linux desktop with GUI will have CLI access via terminal application
- Bash (Bourne again shell) is the most-widely used shell
- The Bourne shell (sh) is one of the oldest Unix/Linux shells
- The Korn shell (ksh) is a tiny shell (tsh) with small and limited functionality shell for systems with limited resources
Graphical User Interface (GUI)
- The pointing device (mouse) is used for input operations where the user clicks on an image or icon as input to the operating system
- Keyboards are for text input
- Multiple windows can be displayed at once, but the user can only interact with one application (and its window)
- Mobile systems include a touch screen that can combine keyboard, pointing device and basic screen functionality into a single device
Linux/Unix GUI
- CDE is the Common Desktop Environment
- X-Windows is a GUI utilized in IBM AIX and SUN Solaris
- KDE is the K Desktop Environment
- GNOME is a GUI often paired with Linux-based operating systems
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This lesson covers key OS concepts including mode bits for CPU, system calls, APIs, and interrupt handling. It explains how applications interact with the kernel and hardware devices. Learn about the role of device controllers and interrupt vectors.