Operating Systems Midterm Part 2

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Parallelism vs. Concurrency

-parallelism: system can perform more than one task simultaneously. will have be on a multicore system. (but one of the cores could still have concurrent execution occurring but so long as the separate cores are parallel it still counts) -concurrency: more than one task making progress. will be on single-core system. -while parallelism is quite literally doing multiple tasks at the same time, concurrency only gives the illusion of switch and just switches off between doing multiple tasks very quickly

Consider a system that has two CPUs, each CPU having two threads (hyperthreading). Suppose three programs, P0, P1, and P2, are started with run times of 5, 15 and 25 msec, respectively. How long will it take to complete the execution of these programs (four possible scenarios)? Assume that all three programs are 100% CPU bound, do not block during execution, and do not change CPUs once assigned.

4 scenarios: all processes run on the same thread concurrently - 45msec P0 and P1 run concurrently on CPU1 and P2 runs on CPU2 - 25msec P0 and P2 run concurrently on CPU1 and P1 runs on CPU2 - 30 msec P1 and P2 run concurrently on CPU1 and P0 runs on CPU2 - 40 msec

cache line

A small amount of storage (between 8-64 bytes) in each cache block. Most heavily used cache line is kept in a high-speed cache located inside or very close to CPU

What is a Operating System?

A software that controls hardware and creates a user interface to run software

Multithreading

A technology that allows multiple parts or threads from a program to run simultaneously.

Read Only Memory (ROM)

A type of memory that contains data that is retrievable but cannot be changed. On some computer, bootstrap loader used to start thecomputer is contained in ROM

What is BIOS?

A. BIOS stands for Basic Input Output System and is a combination of low-level software and drivers that function as the interface, intermediary, or layer between a computer's hardware and its operating system.

What is the biggest advantage of implementing threads in user space? What is the biggest disadvantage?

Advantage: user-level threads package can be implemented on an operating system that does not support threads. Disadvantagel: If one user-level thread performs a blocking operation, the entire process is blocked. Other threads within the same process cannot continue execution until the blocking operation creates. This creates inefficiency. This as well as poor coordination of the threads and the invisibility to the OS due to it being managed by user space

What are the two main functions of OS?

An abstraction as extended machine - Top-down view• Resource manager - Bottom-up View

Kernel Mode

An access mode for applications while they are running on the CPU that allows full access to all hardware devices and memory in the computer.

System call

An instruction that interrupts the program being executed and requests a service from the operating system. (contains a trap instruction)

What is a interrupt?

An interrupt is a signal emitted by hardware or software when a process or an event needs immediate attention

What happens when a computer is booted? (in book)

BIOS is started. It first checks to see how much RAM is installed and whether the keyboard and other basic devices are in stalled and responding correctly. It starts out by scanning the PCIe and PCI buses to detect all the devices attached to them. If the devices present are different from when the system was last booted, the new devices are configured.

Explain howhaving two distinct modes aids in designing an operating system.

Benefits of Dual Modes: Security: Separating user mode from kernel mode prevents user programs from compromising system stability or security. Isolation: User programs cannot directly modify kernel data structures or execute privileged instructions. Fault Tolerance: If a user program crashes, it does not affect the entire system. Resource Protection: Kernel mode ensures that critical resources are managed securely.

Which of the following can only occur in kernel mode: (select all that apply) Disable all interrupts Set time of day clock

Both

CPU is the _______________ of computer

Brain

L1 cache

Built directly on the processor chip Usually has a very small capacity

Consider a multiprogrammed system with a degree of 6 (i.e., six programs in memory at the same time). Assume that each process spends 40% of its time waiting for I/O. What will be the CPU utilization?

CPU utilization = 1 − pn where p is fraction of its time waiting for I/O to complete. AND n is the processes in memory at once SO... 1-.4^6= .9959 = 99.56% usage

To use cache memory, the main memory is divided into cache lines, typically 32 or 64 bytes long. An entire cache line is cached at once. What is the advantage of caching an entire line instead of a single byte or word at a time?

Cache lines exploit the spatial locality principle. When one location is read, nearby locations are likely to be accessed next. Caching an entire line ensures that relevant data is already available in the cache.

L2 Cache (Level 2)

Cache that is slightly slower than L1 cache but has a much larger capacity.

What are the disadvantages of context switching? How to overcome it?

Context switching requires time to save and restore the context of a process. This overhead can be significant, especially for processes with large amounts of data. Issue: Each process requires its own memory space. Frequent context switching can lead to a large amount of memory overhead. Mitigation: Implement lightweight processes (threads) that share memory within a single process.

Which of the following instructions should be allowed only in kernel mode? Disable all interrupts. Read the time-of-day clock. Set the time-of-day clock. Change the memory map.

Disable all interrupts. Set the time-of-day clock. Change the memory map.

Embedded OS

Embedded systems run on the computers that control devices that are not generally thought of as computers and which do not accept user-installed software. Typical examples are microwave ovens, TV sets, cars, DVD recorders, traditional phones, and MP3 players. ROM

All instructions involving I/O and memory protection are disallowed in user mode, and just setting the program status word (PSW) mode bit by user program helps to change the operation mode from user mode to kernel mode.

F

Software that runs in user mode will have complete access to all hardware.

False

Solid-state disks are considered volatile storage.

False

Explain the different levels of abstraction provided by OS for programmers to perform read-write operations on disk blocks?

Hard disks are collections of magnetic disks which hold a number of tracks that have sectors of 512 bytes . when you write to the disk the OS chooses a free sector and writes to it. If you were to do this manually you would need to keep track of all of the sectors you wrote to and which sector holds what information and where is the available space to store new data. Meanwhile, with an OS it does the entire process for you in a faction of the time it would have take to do it manually

Types of interrupts

Hardware interrupt and Software interrupt

What are the three ways the device drivers can be put into the operating system to run in kernel mode?

I/O by Polling, I/O by Interrupts, I/O by Direct Memory Accesss,

Explain how does OS play a role as an extended machine (abstraction) with an example?

In summary, the OS acts as an extended machine by simplifying interactions, shielding users from hardware complexities, and providing a user-friendly interface for tasks like file operations. Example file creation Without an OS abstraction, the user would need to:Write commands to address the disk controller.Initiate input/output (I/O) operations.Check the status of the operation.Handle data movement from disk to memory.

Checkmark the parts listed below that CPU will be having in it.

Instruction set Registers Program counter Stack pointer Program status word MMU (Memory Management Unit)

What are the parts that the CPU is equipped with?

Instruction set, Registers, Program counter, Stack pointer, Program status word, MMU (Memory Management Unit)

Why do we need system calls?

Its the communication means from the user program to OS, and the user programs uses them to request resources from the OS.

further role as a resource manager is to ...

Keep track of which programs are using which resource, To grant resource requests, To account for usage To mediate conflicting requests from different programs and users.13

What is the difference between kernel and user mode?

Kernel Mode: Privileged mode where the operating system runs, with full hardware access. User Mode: Non-privileged mode for user applications, restricted from critical system functions.

what is the difference between the L1 and L2 cache

L1 is smaller but faster while L2 is larger but slower

What is the difference between timesharing and multiprogramming systems?

Multiprogramming is a technique to execute multiple processes concurrently keeping the CPU occupied the entire time Timesharing is a logical extension of Multiprogramming where the processes tasks divides CPU time into small slices for interactive tasks giving the illusion of multiple processes being executed at the same time

What is multithreading? what is the difference between multithreading and parallelism?

Multithreading is a programming technique where multiple threads (lightweight processes) run concurrently within a single process. Each thread represents an independent sequence of instructions that can execute in parallel. Does not offer true parallelism. parallelism involves true simultaneous execution across multiple processes or threads using separate resources

Explain the four events that cause process termination.

Normal exit (voluntary). Example: When a compiler has compiled the program, it executes a system call to inform OS that it has done its job. System calls - exit() in UNIX, ExitProcess() in Windows, Closing word doc, browser or any applications just by clicking close Error exit (voluntary). Error caused by the process due to a bug in program. Executing illegal instruction Referencing non-existing memory Dividing by zero Fatal error (involuntary). Example: attempting to work with or compiling a file that is not exist. Compiler announces this fact by error message and exits. Pop up error messages when anything cannot be done Killed by another process (involuntary). System call - kill() in UNIX, TerminateProcess() in Windows

what does it mean for the OS to be an extended Machine

OS acts as an extended machine by providing an abstraction layer between the hardware and the user's software. The OS bridges the gap between the user's software and the underlying hardware, making computing more accessible and manageable

Handheld Computer OS

OS for tablets, smartphones and other handheld computers Google's Android and Apple's iOS

Mention three difference between process and file tree (hierarchies)

Process hierarchies are not as deep as file hierarchies Process hierarchies are short-lives compared to files hierarchies Ownership and protection differ (The parent process may control or access the child process • Files and directories can be read by group and owner with different privileges.)

What is the difference between a process and a thread?

Process is generally larger whereas threads are smaller Processes encapsulates a complete program with its resources, a thread is more lightweight and focused. Threads are less expensive than process Using threads in most applications is more efficient that processes alone Using threads make programming easier

What is the difference between a process and a program?

Processes (specifically threads) - program in execution and responsible for concurrency A program is a passive entity, such as a file containing a list of instructions stored on disk (often called an executable file) whereas a process is an active entity, with a program counter specifying the next instruction to execute and a set of associated resources programs can turn into more than one process Resource Association: Program: It does not have any resource requirements beyond memory space for storing instructions. Devoid of a control block. Process: Requires resources such as CPU, memory address, and I/O during its lifetime. Has its own control block called the Process Control Block (PCB). Lifetime: Program: Exists at a single place and continues to exist until it is deleted. Process: Exists for a limited span of time—from creation to termination.

The memory address of the next instruction to be fetched by the CPU can be found in

Program Counter

In many CPUs, a register called the __________ stores bit flags representing CPU and program status, including those representing processing errors and the results of comparison operations.

Program status Word (PSW)

Instructions related to accessing I/O devices are typically privileged instructions, that is, they can be executed in kernel mode but not in user mode. Give a reason why these instructions are privileged.

Resource Management: The OS needs to manage I/O devices efficiently. By restricting direct access to privileged instructions, the OS can: Control device allocation (e.g., preventing multiple processes from conflicting over the same device).Implement scheduling policies (e.g., prioritizing I/O requests).Handle errors and recovery (e.g., retrying failed I/O operations). In summary, privileged I/O instructions in kernel mode protect system integrity, manage resources effectively, and prevent unauthorized access to critical devices.

Electrically Erasable PROM (EEPROM) and Flash memory

Rewritable memory

Sensor-node OS

Sensor nodes are tiny computers that communicate with each other and with a base station using wireless communication. Trail cams and sensor lights

device driver

Software that facilitates the communication between a device and the operating system.

From a user point of view, What are the main differences between Windows and Linux?

Some of the main differences include: GUI- many users may prefer Windows GUI over Linux as it is more user friendly SECURITY-Linux is widely considered more secure than windows due the numerous version of Linux and frequent updates. Customizability- Linux in the hands of more experienced users is much more customizable to the user than Windows

What is space sharing

Space sharing: sharing memory space (hard disk, RAM, database) bymany different users (such as in-place algorithms, executing threads)at the same space.4

How are interrupts useful?

Stops the wastage of instruction cycle. Enables multitasking by allowing the CPU to quickly switch between different processes.

volitile storage

Storage available only while the system is on.

Trap Instruction

Switches from User Mode to Kernel mode and starts the operating system.

Explain the four events that cause process creation.

System initialization. -OS booting -OS has specific start up processes that need to run to prepare the system for use Execution of a process-creation system call by a running process. -Running process will issue a system call to create one or more new processes to help it do its job. A user request to create a new process. - In interactive systems, users can start a program by typing a command or (double) clicking on an icon. Initiation of a batch job. - When a batch job is submitted (e.g., compiling a program, processing payroll data, or generating reports), the operating system creates the necessary processes to execute the job.

how do user programs get access to system resources

TRAP instruction

Explain how does OS play a role as a resource manager with an example?

The OS ensures that available resources (such as CPU, memory, I/O devices, and disk space) are allocated effectively among various processes and users. Example: CPU Scheduling: Consider a time-sharing system where multiple processes compete for CPU time.The OS decides which process gets access to the CPU at any given time. It uses scheduling algorithms (e.g., round-robin, priority-based) to allocate CPU time fairly.

CMOS memory

The extremely small storage space that holds user settings and dynamically discovered parameters for the BIOS.

HDD (Hard Disk Drive)

The most common type of hard drive in computers. It includes spinning platters and read/write heads.

What is a TRAP instruction?

The trap instruction is used to switch from user to kernel mode is a mechanism that allows user programs to request services from the operating system and handle exceptional conditions. It ensures a smooth interaction between user-level code and the underlying kernel.

What is time sharing

Time sharing: sharing executing power (such as CPU, logical processor, GPU) by many users (such as OS processes, threads, network requests) at the same time

Multiplexing Types

Time• CPU and multiple programs that want to run on it• Printer and multiple print jobs• Space• Main memory (RAM): CPU and multiple programs that want to run on CPU• Single disk shared amongst many users

What is the function of the CPU?

To fetch, decode and execute instructions

A modern, well-designed operating system still has design flaws.

True

A system call runs in (gets executed in) kernel mode only.

True

Access to the L1 cache is faster than the L2 cache.

True

In a multiprogramming system, context switching occurs between the programs, which is an expensive operation.

True

Multithreading does not offer true parallelism (T or F)

True

Superscalar CPU

Two or more instructions are fetched, decoded and dumped into buffer Once the execution unit is available it will select one from the buffer to execute

A computer has a pipeline with four stages. Each stage takes the same time to do its work, namely, 1 nsec. How many instructions per second can this machine execute?

Two scenarios: all stages done in parallel: 1 billion instructions per second all stages done concurrently (like a pipeline) 250 million instructions per second

What is virtual memory and virtual memory address?

Virtual memory is a feature of an operating system that allows a computer to compensate for shortages of physical memory by temporarily transferring pages of program data from main memory to disk storage. It maps memory addresses used by a program, called virtual addresses, into physical addresses in computer memory.8

cache hit

When requested data is found in cache

how does the CPU pipelining work

While executing nth instruction, it is possible to decode n+1 instruction and fetch n+2 instruction at the same time

SSD (solid state drive)

a storage device containing nonvolatile flash memory, used in place of a hard disk because of its much greater speed.

Real-time OS

characterized by having time as a key parameter For machines that must have a task done at a certain time Robotic assembly lines

CPU Cores

complete processors within a CPU

Smart card OS

credit-card-sized devices containing a CPU chip. electronic payments Think chip in your credit card

Write the appropriate protection code for a directory where the owner has read, write, and execute permission, group members have read and write permission, and everyone else has read and execute permission.

drwxrw-r-x

what takes longer fetching data out of memory or executing an instruction on the CPU?

fetching data out of memory

What are the reasons for having threads within a process?

for running processes with many activities. (it breaks up the process into smaller more digestible pieces for the CPU) thread are more light weight I/O bound processes are improved Real parallelism is possible (When using multiple CPUs, Threads run simultaneously on separate cores, providing significant performance gains.)

Stack pointer -

frame for each procedures contains input parameters, local variables, and temporary variables that are not kept in registers

What is i-Node? Explain its use in operating systems.

i-Node, one per file, a data structure used to represent a filesystemobject, telling who owns the file, where its disk blocks are, and so on9

How does as a thread appear to the OS?

like a separate CPU

Program counter -

memory address of the next instruction to be fetched

User Mode

mode that provides an interface between an application and the OS, and only has access to hardware resources through the code running in kernel mode.

User can normally read the entire PSW, but can they write to all of its fields

no, users may only write to a few of the PSW fields

What are the important distinctions and other aspects between an operating system and normal software?

operating system manages the entire system, while normal software serves specific user needs OS are huge Software is relatively smaller OS are essential where as Software is not OS runs on the raw machine where software runs on the OS OS has direct access to the hardware where software has to request resources form the OS

Mainframe OS

operating systems for mainframes The operating systems for mainframes are heavily oriented toward processing many jobs at once, most of which need prodigious amounts of I/O

Multiprocessor OS

parallel computers (multiple CPUs into a single system) variations of the server operating systems

Explain pipeline vs superscalar CPU.

pipeline - A technique that implements a form of parallelism called instruction-level parallelism within a single processor. It therefore allows fasterCPU throughput (the number of instructions that can be executed ina unit of time) than would otherwise be possible at a given clock rate.7 superscalar- more advance version of the pipeline that is more efficient. this is done by multaneously dispatch multiple instructions to different execution units within a single processor. These execution units handle tasks like arithmetic operations, memory access, and control flow. By allowing more throughput, superscalar processors improve performance.

Instructions related to accessing I/O devices are typically privileged instructions. Give a reason why these instructions are privileged

privileged I/O instructions maintain system integrity, prevent unauthorized access, and ensure proper resource allocation. By enforcing privilege levels, the operating system safeguards against potential misuse or disruption

Context Switching

procedure by which, when the next process takes control of the CPU, its previous state is reinstated or restored.

Personal Computer OS

provide good support to a single user used for word processing, spreadsheets, games, and Internet access. Examples are Linux, FreeBSD, Windows 10, Windows 11, and Apple's OS X

Server OS

run on servers serve multiple users at once over a network and allow the users to share hardware and software resources. Servers can provide print service, file service, or Web service.

RAM (Random Access Memory)

stores the computer's programs and data temporarily while power is on. (volatile memory)

What is the problem with I/O by polling device?

when using I/O by polling it lock the CPU in a "busy waiting" state that prevents the CPU form preforming any tasks in the meantime


Ensembles d'études connexes

Intermediate Accounting 1- D103: Units 2-4 Pre-Assessment

View Set

447 - File Systems - Content - Slone. B

View Set

¡QUÉ CHÉVERE! 5 Unidad 5. Actividad 12. Pág. 135. ¿Qué es el amor?

View Set

Cognitive Distortion Matching Game

View Set