Operating System Concepts - Mega Midterm

Ace your homework & exams now with Quizwiz!

kernel

"The one program running at all times on the computer" is the kernel.

bounded buffer

(buffer of a fixed size) - consumer must wait if buffer is empty and consumer must wait if buffer is full.

Types of system calls

- Process control - File Management - Device Management - Information Management - Communications

Goals of Operating System

-Execute user programs and make solving user problems easier -Make the computer system convenient to use -Use the computer hardware in an efficient manner

4 components of computer system

-Hardware-provides basic computing resources(CPU mem , I/O device) -OS- Controls various and corrdinates use of hardware among applications and users -Application program- word processes, ect -Users- people, machines, other computers

In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems. what are two such problems? b. Can we ensure the same degree of security in a time-shared machine as in a dedicated machine?

-Users could have access to other peoples files when they should not. -A user may accidentally write over another user's files in memory. No. Time-shared machines have a lot of processes going on at the same time so it is much more difficult to secure and make sure users are not accessing things they shouldn't.

To start I/O operation:

1. Device driver loads appropriate registers within the device controller. 2. Device controller examines content of registers to determine what action to take. 3. Controller starts the transfer of data from device to local buffer. 4. Device controller informs device driver via interrupt that is has finished its operation. 5. Device driver returns control to OS

Interrupt Handling

1. The OS preserves the state of the CPU by storing registers and program counter. 2. Determines which type of interrupt has occurred: polling/vectored. 3. Separate segments of code determine what action should be taken for each type of interrupt.

What is Operating System?

A program that acts as an intermediary between a user of a computer and the computer hardware -Resource allocator -Resource Manager -Decides btwn conflicting requests -OS is control program

Sockets

A socket is defined as an endpoint for communication Communication between sockets - some have known port numbers, client process may be assigned an arbitrary number > 1024 that is not being used Communication exists between a unique pair of sockets

trap

A software-generated interrupt caused either by an error or a user request.

Real Time System

A system that will get a process done within a certain amount of time guaranteed.

Aging

A technique to prevent starvation. CPU scheduling that can cause starvation are priority, and SJF scheduling.

Target thread

A thread that is to be canceled.

Two-level model

A variation on the many-to-many model that multiplexes many user-level threads to a smaller or equal number of kernel threads but also allows a user-level thread to be bound to a kernel thread.

Batch system

All the processes that need to be completed are in a queue and preformed one at a time until complete.

Process

An abstraction of a running program, a program in execution.

Symmetric multiprocessing

Approach to processor scheduling that allows each processor to self-schedule.

Benefits of multithreading

Benefits from this practice include increased responsiveness to the user, resource sharing within the process, economy, and scalability issues such as more efficient use of multiple cores.

Basic architecture of computer system

CPU Device Controllers System Bus Shared Memory

Multiple-Processor Scheduling

CPU scheduling more complex when multiple CPUs are available Homogeneous processors within a multiprocessor Load sharing Asymmetric multiprocessing - only one processor accesses the system data structures, alleviating the need for data sharing

Preemptive Scheduling

CPU-scheduling decision that takes place when either 1: a process switches from the running state to the ready state, or 2: when a process switches from the waiting state to the ready state. This type of scheduling can stop a running task before completion so another task can use the CPU.

Nonpreemptive Scheduling

CPU-scheduling decision that takes place when either 1: when a process switches form the running state to the waiting state, or 2: when a process terminates. This type of scheduling doesn't interrupt a task before completion for another task to use the CPU.

Two main user interfaces provided by OS

Command Line GUI

Three reasons systems provide services for IPC

Computational Speed up modularity usage of multi-core system

Device Controllers

Control specific devices (disk drive, audio devices, video display ...) CPU and device controllers can execute concurrently. Maintains some local buffer storage and a set of registers. It is responsible for moving the data between the peripheral devices that it controls and its local buffer storage.

Memory Controller

Controls (synchronizes) access to memory.

Thread Pool

Creating a number of threads that wait for work. When a thread completes its service it returns to wait for more work. If there are no available threads the server waits until one becomes available.

Scheduling

Determining when processors should be assigned and to which processes.

Operating System Services

File System management Process Management Memory Management I/O System Management Security and protection

Real-Time Scheduling

Hard real-time systems - required to complete a critical task within a guaranteed amount of time Soft real-time computing - requires that critical processes receive priority over less fortunate ones

Thread Scheduling

Local Scheduling - How the threads library decides which thread to put onto an available LWP Global Scheduling - How the kernel decides which kernel thread to run next

problems of message passing

Lost messages - often receiver sends acknowledgment of message Lost acknowledgments - unique identification of original message so that receiver can distinguish new messages from old messages. Process identification Process authentication - making sure the receiver isn't an imposter.

Cluster System

Many computers working together to perform a single task

One-to-One Model

Mapping each user thread to a kernel thread. It provides more concurrency than the many-to-one model. The only drawback to this model is that creating a user thread requires creating the corresponding kernel thread.

Many-to-One Model

Mapping many user threads to one kernel thread. Thread management is done by the thread library in user space, so it is efficient; but the entire process will block if a thread makes a blocking system call. Multiple threads are unable to run in parallel on multiprocessors.

Multilevel feedback queues

Mechanism that allow processes to move from one queue to another (example: from foreground to background).

Two models for interprocess communication (IPC)

Message passing Shared Memory Model

When a process it blocks it

Moves from execute state to blocked state

Many-to-Many Model

Multiplexing many user-level threads to a smaller or equal number of kernel threads. Developers can create as many user threads as necessary, and the corresponding kernel threads can run in parallel on a multiprocessor as they become available.

On Linux when one executes a fork the parent process and the child process shares

NOTHING

disadvantage of threads

Need a thread table for each thread - state, PC reg,... Must determine thread managmen

Process States :

New - process is being created Ready - process is ready for the CPU Running - process is currently executing Blocked (waiting)- process is blocked/waiting on an event to occur Terminated - process is done executing (aborted or ended)

Layered Approach

OS is divided into a number of layers, each built on top of lower layers. The bottom layer is hardware, the top is user interface. - Layers are selected such that each uses functions and services of only lower-level layers. - Adv: Simplicity of construction; debugging - Dis: Less efficient

kernel level

OS must manage & schedule threads, lose the benefits of low Overhead in context switching.

Parallel System

Parallel computing happens when a machine runs multiple processors at a time so it can split up processing and run jobs more efficiently.

PCB contains

Process Control Block - the entry for a single process. Process state Program counter CPU registers CPU scheduling information Memory-management information File-management information Accounting information I/O status information

Info the process manager will maintain about a process in PCB

Process State PC process I/O file system info PID

exit

Process has terminated, remove from system.

block

Process issues an I/O request and must wait for I/O to finish or process is waiting for a "signal" of an event (timer...).

Race condition

Producer-consumer problem - using a shared variable "count" - the consumer retrieves the value and is interrupted by the scheduler, the producer gets the CPU before the consumer's next turn and alters the contents of count. The next time the consumer gets the CPU it will be working from the old value of count, decrement it and store it back in count thus completely losing one of the produced items.

bootstrap

Program loaded at power-up or reboot. Initializes the system and loads the OS kernel and starts execution.

Shortest-job-first scheduling (SJF)

Provably optimal scheduling, that provides the shortest average waiting time. Implementation is difficult because predicting the length of the next CPU burst is difficult.

System Calls

Provide an interface to operating system services

Network System

Provides shared resources and shared operation system between a connection of multiple computers.

dispatch

Scheduler moves a process from the front of the ready to run queue to the CPU.

Long Term Scheduler

Scheduler that controls the degree of multiprogramming

Round-robin scheduling (RR)

Scheduling that is more appropriate for a time-shared interactive system. It allocates the CPU to the first process in the ready queue for q time units, where q is the time quantum. After q time units, if the process has not relinquished the CPU, it is preempted, and the process is put at the tail of the ready queue.

Short-term scheduler

Selects which process should be executed next and allocates CPU Executes frequently

Asymmetric multiprocessing

Simple multiple processor scheduling approach that allow a single processor - the master server, to handle all CPU scheduling, i/o processing, and other system activities.

Storage systems organized in hierarchy

Speed Cost Volatility

Distributed System

Splits up jobs between processors that have their own local memory and communicate between processors through a bus.

process includes:

Text section stack heap data section Process state Program counter CPU registers CPU scheduling information Memory-management information Accounting information I/O status information

Interrupt

The occurrence of an event is usually signaled by an interrupt from either the hardware or the software. Hardware: signal to CPU; Software: execute a system call; The CPU stops what it is doing and immediately transfers execution to a fixed location.

Interrupt Cycle

The processor checks to see if any interrupts have occurred, indicated by an interrupt signal. If no interrupts have occurred then the processor proceeds to the fetch cycle. If an interrupt is pending then the processor suspends execution of the current job and executes the interrupt handler routine (generally part of the OS).

Execute Cycle

The processor interprets the bits in the IR and performs the indicated activity:

Short-term scheduler

The scheduler that selects a process form the processes in memory that are ready to execute and allocates the CPU to that process

First-come, first-severed scheduling (FCFS)

The simplest scheduling algorithm but it can cause short processes to wait for very long processes.

Time Sharing System

The system switches between users' programs by making a schedule so it can support multiple users.

Interactive System

The system waits for user input to run program.

CPU Scheduling

The task of selecting a waiting process from the ready queue and allocating the CPU to it. The CPU is allocated to the selected process by the dispatcher.

Operating System Objectives

To facilitate: User interface communication between application software and components communication among computer system components maximize throughput - schedule so that all resources are optimized. optimize the use of computer resources maintain the file system. provide system security - secure resources, processes, files... monitor computer system and alert user of potential problem

Shared Memory

Two processes agree to open restrictions on a portion of memory... Exchange of information is done by reading and writing too and from this memory.

Thread

Unit of execution we use to dispatch lightweight process (LWP) - basic unit of the CPU Consists of a program counter, register set, and stack space.

Direct Memory Access (DMA)

Used for high-speed I/O devices able to transmit information at close to memory speeds. Device controller transfers blocks of data from buffer storage directly into main memory without CPU intervention. Only one interrupt is generated per block, rather than one per byte.

Signal

Used in UNIX systems to notify a process that a particular event has occurred.

User goals vs System goals (OS Design)

User goals: OS should be convenient to use, easy to learn, reliable, safe, and fast. System goals: OS should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

Fetch Cycle

Using the address in the PC the next instruction is retrieved from memory and loaded into the IR. The PC is incremented in preparation for the next fetch.

Cache

Volatile, fast storage. Useful when two or more components need to exchange data and the components perform transfers at different speeds. The data in the cache must be kept consistent with the data in the components.

mulitprocessor

a computer system that has more than one core

mailbox

a named data structure used for buffering messages. Messages are directed and received from mailboxes (also referred to as ports). Each mailbox has a unique id. Processes can communicate only if they share a mailbox. send(A, message) - send a message to mailbox A receive(A, message) - receive a message from mailbox A

Three ways to pass parameters for a system call

a. Pass parameters in registers b. Registers pass starting addresses of blocks of parameters c. Parameters can be placed, or pushed, onto the stack by the program, and popped off the stack by the operating system

Message Passing

allows interprocess communication using two primitives: send & recv. (no shared address space!)

Stubs

client-side proxy for the actual procedure on the server.

unbounded buffer

consumer may wait for new items, but producer can always produce new items ( linked list of virtual memory locations)

File System Management OS Responsibility

create/delete files manage free space organize files- directory, structure mapping/indexing for quick access

Process management OS responsibilites

create/delete process keep track of processes provide process synchronization provide process communication provide mechanisms to detect problems- dead lock

CPU registers

data registers- general purpose address registers- index, seg ptr, stack ptr condition code registers- flags control and status registers- MAR, MBR, I/O AR, I/O BR, PC, IR

I/O System Management OS Responsibility

device interface drivers fro devices mem mgmt for devices for buffering and caching

examples of software interrupt

division by zero system call shut down procedures

advantage of threads

easy to share memory between threads one thread can block while others can still run context-switching between threads decreases overhead.

Secondary storage

extension of main memory that provides large nonvolatile storage capacity

Instruction Cycle

fetch/decode execute check for interrupt

Multithreads of the same process share

global variables heap memory

asymmetric multiprocessing

has master-slave relation; master server does the scheduling

Registers

high speed storage locations

user level thread

if thread executes system call and blocks then entire task is blocked.

Things that make processes block

interrupt (see that Q)

Timesharing (multitasking)

logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing

Memory Management Os responsibilities

manage free space manage security btwn proc in mem optimize mem allocate and deallocate memory to proc provide error detection and recovery

examples of hardware interrupt

moving your mouse key press click mouse timer

4 conditions that must hold for proper sharing of critical resource

mutual exclusion progress Can make no assumptions of CPU speed or size bounded waiting

admit

new process is admitted to the system (ex: fork)

symmetric multiprocessing

one common ready queue each processor is self-scheduling each processor examines the common ready queue and selects a process to execute

Main memory

only large storage media that the CPU can access directly

Multiprogramming

os keeps several jobs in memory simultaneously Needed for efficiency - CPU never idle. The OS keeps several jobs in memory simultaneously. One job selected and run via job scheduling. When it has to wait (for I/O), OS switches to another job.

Two benefits of using multithreads

parallel programming If one proc blocks other processes can still execute

process

program in execution

interrupt

quantum expired, "times up" (quantum - Interval of time a process can use the CPU)

Magnetic disks

rigid metal or glass platters covered with magnetic recording material

Multithread of the same process do not share

stack pc register **

Context Switch

switching the CPU from one process to another

fork( )

system call creates new process

exec( )

system call used after a fork( ) to replace the process' memory space with a new program.

Device-status table

table containing an entry for each device type, address, and status (busy, idle...).

test and set

the hardware solution to mutual exclusion that reads the contents of memory into a register then stores a nonzero value in the memory location as an indivisible instruction

critical section

the section of code in a process that accesses/modifies shared memory

kernel threads

threads managed by the kernel

Dispatch latency

time it takes for the dispatcher to stop one process and start another running

Security and Protection OS Responsibility

user id/ process id mechanism group ids private assoc. w/ groups/users/processes

the mode bit distinguishes between what modes (dual modes)

user mode and monitor mode

wakeup

vent is complete, process can "run" again.


Related study sets

NSE 4 Security 6.2 - Application Control

View Set

MATERNAL NEWBORN COMPLETE STUDY SET

View Set

FST 1: Lecture 2, World Food Problems:

View Set

PARTS OF A RESEARCH JOURNAL ARTICLE

View Set

Unit 4 Chapter 2 Section 3 Tides

View Set