Operating System Concepts
53 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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?

  • 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?

  • 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?

<p>In dynamic link libraries (DLLs). (D)</p> Signup and view all the answers

What is the primary benefit of using an API between normal programs and the operating system?

<p>It hides the details of the O/S interface from the programmer, providing a level of abstraction. (A)</p> Signup and view all the answers

In Unix-like systems, what is the API that typically sits between normal programs and the operating system?

<p>A part of the C library (libc). (D)</p> Signup and view all the answers

What occurs when a function call is made in a program?

<p>A piece of code is loaded into user space to perform a specific task. (B)</p> Signup and view all the answers

What is the role of the C standard library functions in programming?

<p>They offer built-in functions that a program can call to perform common tasks. (C)</p> Signup and view all the answers

What is the primary role of the operating system in handling application requests to access hardware devices?

<p>To mediate access by initiating system calls and translating application requests into device-specific instructions. (A)</p> Signup and view all the answers

How does a device controller typically signal the CPU upon completion of a task?

<p>By triggering a hardware interrupt. (C)</p> Signup and view all the answers

What information does the interrupt vector provide to the CPU when an interrupt occurs?

<p>The memory address of the interrupt handler routine. (A)</p> Signup and view all the answers

Which of the following events would typically trigger a hardware interrupt?

<p>Data arriving at a Network Interface Card (NIC). (B)</p> Signup and view all the answers

What is the key difference between a trap (exception) and a hardware interrupt?

<p>Traps are software interrupts triggered by applications or system programs, while hardware interrupts are triggered by hardware events. (A)</p> Signup and view all the answers

Which of the following scenarios would most likely result in a software interrupt (trap)?

<p>A program attempts to modify the data of another running program. (B)</p> Signup and view all the answers

What is the primary purpose of privilege levels within an operating system?

<p>To protect system hardware and the operating system itself by restricting the CPU instructions that can be executed at different levels. (C)</p> Signup and view all the answers

In the context of operating system privilege levels (protection rings), what is the significance of Ring 0?

<p>It is the level with the most privileges, interacting directly with the physical hardware. (A)</p> Signup and view all the answers

In an operating system employing protection rings, what is the primary security benefit of isolating user applications to Ring 3?

<p>It prevents user applications from directly accessing hardware or critical system resources. (C)</p> Signup and view all the answers

Why do virtualization platforms like VMware place guest kernels in Ring 1 rather than Ring 0?

<p>To enable the host OS to maintain control and prevent the guest OS from directly accessing hardware. (A)</p> Signup and view all the answers

When a user application requires a service from the operating system, such as writing to a file, how does it typically request this service?

<p>By executing a system call, which switches the execution mode to privileged mode. (B)</p> Signup and view all the answers

What is the primary purpose of privilege escalation, such as using sudo in Linux or 'Run as administrator' in Windows?

<p>To allow a user to temporarily gain elevated permissions to perform administrative tasks. (D)</p> Signup and view all the answers

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?

<p>The operating system's file permission system, tied to the User ID. (A)</p> Signup and view all the answers

Why is it important for processes to execute within their own assigned address space?

<p>To prevent processes from corrupting each other's data or the operating system itself, enhancing system stability. (A)</p> Signup and view all the answers

What happens when a program running in user mode (Ring 3) requires access to a hardware resource, such as controlling a printer?

<p>The program uses a system call to request the operating system to perform the hardware operation on its behalf. (B)</p> Signup and view all the answers

How do operating systems ensure that multiple users can concurrently access system resources without causing conflicts or data corruption?

<p>By implementing access control mechanisms, process isolation, and system calls to manage and mediate resource access. (A)</p> Signup and view all the answers

What is a primary reason many Linux servers are configured to operate solely with a command-line interface (CLI)?

<p>To enhance system performance and security. (B)</p> Signup and view all the answers

How do external commands differ from built-in commands in a command-line interface (CLI)?

<p>External commands are separate programs loaded and executed by the shell, while built-in commands are part of the shell program itself. (C)</p> Signup and view all the answers

A system administrator needs to manage a Linux server with limited resources using a minimal shell. Which shell would be the most appropriate choice?

<p>Tiny shell (tsh) (C)</p> Signup and view all the answers

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?

<p>Users can only interact with one application (and its window) at a time. (B)</p> Signup and view all the answers

Which of the following best describes the role of a touch screen in a mobile operating system?

<p>Combines keyboard, pointing device, and basic screen functionality into a single device. (D)</p> Signup and view all the answers

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?

<p>Command Line Interface (CLI) (A)</p> Signup and view all the answers

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?

<p>PowerShell (C)</p> Signup and view all the answers

Which of the following is an example of a desktop environment that relies on X-Windows?

<p>CDE (A)</p> Signup and view all the answers

When a process transitions to the 'Waiting' state, what is it typically waiting for?

<p>An interrupt or other event to occur. (C)</p> Signup and view all the answers

What is the primary function of the Program Counter (PC) register?

<p>To hold the address of the next instruction to be executed. (C)</p> Signup and view all the answers

Which of the following memory segments is used for storing variables without a default value?

<p>BSS (D)</p> Signup and view all the answers

Why is it necessary to save the contents of registers and the program counter during multitasking?

<p>To ensure correct resumption of a process after its time slice. (B)</p> Signup and view all the answers

Which of the following best describes the role of the 'Heap' in process memory management?

<p>Dynamically allocating memory during runtime. (B)</p> Signup and view all the answers

What information is contained within a Process Control Block (PCB)?

<p>Information used by the operating system to manage and monitor the process. (D)</p> Signup and view all the answers

Which of the following scenarios best illustrates the concept of preemptive multitasking?

<p>The operating system interrupts a running process after a fixed time slice to allow another process to execute. (A)</p> Signup and view all the answers

How do Base and Limit registers contribute to memory protection in an operating system?

<p>By defining the range of accessible memory addresses for a process. (A)</p> Signup and view all the answers

A computer has a single CPU. Which of the following is the most accurate description of how it appears to run multiple programs simultaneously?

<p>The CPU rapidly switches between different programs, allocating time slices to each, creating the illusion of simultaneous execution. (D)</p> Signup and view all the answers

Which of the following statements correctly describes the key difference between multiprocessing and multithreading?

<p>Multiprocessing requires multiple CPUs or cores, while multithreading can occur on a single CPU. (D)</p> Signup and view all the answers

A program is considered a ___, while a process is considered ___.

<p>Passive entity, active entity (D)</p> Signup and view all the answers

An operating system receives an interrupt from a network interface card (NIC). What is the most likely immediate action the OS will take?

<p>Suspend the current process and execute an interrupt handler to service the NIC. (C)</p> Signup and view all the answers

How does the stack typically manage memory allocation?

<p>Allocating memory from the highest available address downwards. (D)</p> Signup and view all the answers

At what 'Ring level' do command line interfaces typically operate, and what is its significance?

<p>Ring level 3, indicating user-level operations with restricted privileges. (B)</p> Signup and view all the answers

What is the primary purpose of multiprogramming in an operating system?

<p>To increase CPU utilization by keeping it busy even when one program is waiting for I/O. (D)</p> Signup and view all the answers

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?

<p>Keystroke -&gt; Hardware interrupt -&gt; O/S handling -&gt; Screen display (B)</p> Signup and view all the answers

Which statement accurately compares cooperative multitasking with preemptive multitasking?

<p>Cooperative multitasking can lead to system crashes if a process enters an infinite loop. (B)</p> Signup and view all the answers

What is the role of a device controller in the interaction between an application and a hardware device?

<p>It manages the specific hardware device and translates operating system commands into device-specific actions. (D)</p> Signup and view all the answers

Why are operating systems typically designed to be interrupt-driven?

<p>To allow the OS to efficiently respond to asynchronous events from hardware and software. (C)</p> Signup and view all the answers

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?

<p>Employing multiprogramming to allow other programs to run while the program is waiting for disk I/O. (A)</p> Signup and view all the answers

Signup and view all the answers

Flashcards

Multitasking

Executing multiple programs seemingly at the same time by rapidly switching between them.

Multiprogramming

Loading multiple programs into memory to increase CPU utilization by switching between them.

Multiprocessing

Using multiple CPUs or processor cores to execute instructions simultaneously.

Multithreading

Directing multiple strings of commands to different processors to be executed in parallel.

Signup and view all the flashcards

Time slice

A scheduled segment of time allocated to a process for execution.

Signup and view all the flashcards

Pre-emptive multitasking

Interrupting the current process to switch to another, based on priority or scheduling.

Signup and view all the flashcards

Interrupt

A signal that disrupts the CPU to handle an event, like a network packet arrival.

Signup and view all the flashcards

Hardware Interrupt

A hardware signal sent from a device to the CPU via control bus.

Signup and view all the flashcards

Event-driven

When the OS waits for an event to initiate action, such as a user opening a program.

Signup and view all the flashcards

Device controller

A component that manages a specific device, such as managing data transfer.

Signup and view all the flashcards

System Call

A request from an application to the operating system to access a device.

Signup and view all the flashcards

Interrupt Vector

A data structure containing pointers to interrupt handlers.

Signup and view all the flashcards

Interrupt Handler

A routine that handles a specific device request triggered by an interrupt.

Signup and view all the flashcards

Trap (or Exception)

A software-generated interrupt from an application or system program requesting a service or action.

Signup and view all the flashcards

Privilege Levels (Protection Rings)

Multiple levels used by the OS to protect system hardware and the OS itself.

Signup and view all the flashcards

Ring 0

The most privileged level that interacts directly with hardware.

Signup and view all the flashcards

Ring 1 & 2

Hardware device drivers have privileges.

Signup and view all the flashcards

User Mode

Prevents access to system instructions that can damage the hardware.

Signup and view all the flashcards

Kernel Mode

Privilege Mode or System Mode.

Signup and view all the flashcards

Concurrent

Multiple users and processes run at the same time.

Signup and view all the flashcards

Privilege escalation

Allows a user to change to an effective ID with more rights.

Signup and view all the flashcards

System call function

A programming interface to the operating system with a request to switch from user mode to privileged mode.

Signup and view all the flashcards

Mode Bit

A bit used by the CPU to indicate the level of access/permissions; 0 = Kernel Mode, 1 = User Mode.

Signup and view all the flashcards

Application Programming Interface (API)

Libraries that simplify system calls for programmers.

Signup and view all the flashcards

API Functions

A collection of available functions for application programmers.

Signup and view all the flashcards

DLLs in Windows API

Windows API functions stored in dynamic link libraries.

Signup and view all the flashcards

API Abstraction

The API hides the specifics of the OS interface from the programmer.

Signup and view all the flashcards

API in Unix-like Systems

In Unix-like systems, the API is often part of the C library (libc).

Signup and view all the flashcards

Function Call

Loading a piece of code into user space to perform a specific task. Once done, control is passed back to the main program.

Signup and view all the flashcards

Command Line Interface (CLI)

Programs used to interact with the operating system, available on Windows, Mac OSX, and Linux.

Signup and view all the flashcards

Built-in Commands

Commands that are integral parts of the shell program, executing within the same process.

Signup and view all the flashcards

External Commands

Separate programs loaded and executed by the shell, residing outside the shell's core.

Signup and view all the flashcards

Command Prompt

A Windows shell based on MS-DOS, offering basic command-line functionality.

Signup and view all the flashcards

PowerShell

A newer, more powerful Windows shell with extended functionality.

Signup and view all the flashcards

Bash (Bourne Again Shell)

Most widely-used shell in Linux.

Signup and view all the flashcards

Multiple Windows

Allow multiple programs to be displayed at once, but users can only interact with one application at a time.

Signup and view all the flashcards

CDE

Common Desktop Environment.

Signup and view all the flashcards

Program

A passive set of instructions stored, for example, on a hard drive.

Signup and view all the flashcards

Process

An active instance of a program in execution.

Signup and view all the flashcards

Process ID (PID)

A unique identifer assigned to each process by the OS.

Signup and view all the flashcards

Register (CPU)

A small, high-speed storage location inside the CPU used to hold data and instructions during processing.

Signup and view all the flashcards

Program Counter

A special register that keeps track of the address of the next instruction to be executed.

Signup and view all the flashcards

Process Control Block (PCB)

A data structure containing information needed to manage a process.

Signup and view all the flashcards

Process state: New

The process is being initialized by the operative system.

Signup and view all the flashcards

Process state: Running

The process is actively executing instructions on the CPU.

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.

Quiz Team

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.

Use Quizgecko on...
Browser
Browser