2INC0 - Operating Systems

¡Supera tus tareas y exámenes ahora con Quizwiz!

Single reference rule

A statement (expression) may be regarded as atomic if it makes at most one reference to a shared variable.

A system supporting POSIX provides:

A system supporting POSIX provides: • a host language and compiler (often: C) • programming interface definition files (e.g., C-header files) • programming interface implementation binary or code (e.g., C-libraries) • a run-time system (a platform: OS or the like)

Blocked Task

A task is blocked if it is waiting on a blocking synchronization action

Trap/Exception

A trap or exception is a software generated interrupt • caused either by a software error (e.g. division by zero, floating pt error) • or by a system call

Condition synchronization

Explicit communication (signalling) between tasks when just counting is not enough to solve a synchronization problem. Two principles: >Where a condition may be violated: check and block >Where a condition may have become true: signal waiters

Advantages of virtual memory

Advantages: + Process size is no longer restricted to main memory size (or the free space within main memory) + Memory is used more efficiently > Eliminates external fragmentation when used with paging > Reduces internal fragmentation + Placement of a program in memory does not have to be known at design time + Facilitates dynamic linking of program segments + Allows sharing of code and data (by sharing access to pages)

Advantage of Priority scheduling

Ageing - increase the priority of the process over time.

Many-to-many Multithreading model

Allows OS to create a (limited) number of kernel threads (#kernel_threads ≤ #user_threads) Advantages: • concurrency (Concurrency level is limited by the number of kernel threads) • bounded performance cost for the kernel • Disadvantage: more complex to implement

Reusable resources

Resources are given back after use (➔number of resources is fixed) • Typically, readers/writers type of problems or mutual exclusion (critical section) • examples: processor, memory blocks, physical entities, shared variables, buffer spaces, ...

Disadvantages of Single-programmed solution

Problems: • No multiprogramming support. • Large context-switch overhead • If a program does not fit in the memory,it cannot be executed.

Consumable resources

Resources is taken away upon use (➔number of resources varies) • Typical producer / consumer problems • examples: sensor data, characters typed using a keyboard, blocks of data received from the network, ...

Two-level Multithreading model

Similar to many-to-many, except that it allows a user thread to be bound to a kernel thread

How are iOS and Android similar? How are they different?

Similarities: > Both are based on existing kernels > Both have architecture that uses software stacks > Both provide frameworks for developers Differences: < iOS is closed-source, and Android is open-source < Android uses a virtual machine and iOS executes code natively

Peterson's algorithm

Combine the ideas of the last two solutions: • take turns in crowded circumstances (use a variable t) • don't wait if there is no need (look at the boolean bY or bX) Limitations of Peterson's algorithm: - Can synchronize only two tasks (extension for more tasks exists but more complex) - Busy-wait (wastes CPU cycles, does not work for single core if the scheduling policy is non-preemptive)

Requirements on synchronization solutions

1. Functional correctness: satisfy the given specification (e.g., mutual exclusion) - an assertion that is needed for correctness must not be disturbed (by another process). 2. Minimal waiting: ("make progress"): waiting only when correctness is in danger. 3. Absence of deadlock: don't manoeuvre (part of) the system into a state such that progress is no longer possible. 4. Absence of livelock: ensure convergence towards a decision in a synchronization protocol 5. Fairness in competition: absence of fairness leads to starvation of processes.

Disadvantages of Process

- Creation overhead (e.g., memory space creation/copy) - Complex inter-process communication - Process switching overhead: mode + context switch ( for each inter-process communication (IPC) on a single-processor system, save/restore state)

Process Creation

- Parent process creates children processes, which, in turn creates other processes, forming a tree of processes - Generally, process identified and managed via a process identifier (pid) - When a process creates children, it can share its memory or resources (such as files) with them. Resource sharing options: • Parent and children share all resources • Children share subset of parent's resources • Parent and child share no resources Execution options • Parent and children execute concurrently • Parent waits until children terminate Address space options • The child is a copy of the parent (e.g., default in Linux) • The child has a new program loaded into its address space (e.g., Windows)

Preventing deadlock

-Always let critical sections terminate: always call unlock(m) after lock(m) -Avoid cyclic waiting • Try to avoid P or lock operations that may block indefinitely between lock(m) and unlock(m) • Use a fixed order when calling P-operations on semaphores or mutexes− P(m);P(n); .... in one task may deadlock with P(n);P(m);... in another task • Look for the "dining philosopher problem" for a good example - Avoid greedy consumers: P(a)k should be an indivisible atomic operation when tasks compete for limited resources

Describe three general methods for passing parameters to the operating system.

1. Pass parameters in register. 2. Registers pass staring address of blocks of parameters. 3. Parameters can be placed, or pushed, onto the stack by the program, and popped off the stack by the operating system.

What does an operating system provide?

1. Process management (Creation and deletion, Scheduling, Synchronization) 2. Memory management ( Allocate and deallocate memory space as requested) 3. I/O management (A buffer-caching system) 4. File management (Manipulation of files and directories) 5. Error detection (Debugging facilities) 6. Protection (concurrent processes should not interfere with each other (memory)) 7. Security (Against other processes and outsiders) 8. Accounting (Using timers)

What would we expect from an ideal memory?

> Simple to use: The programmer should not have to know where data and code are loaded > Private (isolation): Tasks should be able to share only what they want to > Non-volatile / permanent: Data and code should always be available in memory >Fast access: For better performance > Huge (unlimited) capacity: To be able to execute large programs and treat lots of data > Cheap: To be cost-effective Conflicting requirements! We use a memory hierarchy and virtualization to find a good tradeof.

Deadlocked set

A set of task Dis deadlocked if 1. all tasks in Dare blocked or terminated (normally or abnormally), 2. there is at least one non-terminated task in D, and 3. for each non-terminated task T in D, any task that might unblock T is also in D.

Deadlock state

A deadlock state is a system state in which a set of tasks is blocked indefinitely: • each task is blocked on another task in the same set We typically prove the absence of deadlock by contradiction 1. assume a deadlock occurs 2. investigate all task sets that can be blocked at the same time (often: just 1) 3. show a contradiction for all possible combinations of blocking actions of those tasks

Monitor

A monitor is an object that contains a combination of data and operations on those data • Data record the state of the monitor • Procedures of a monitor are executed under mutual exclusion. (At most one task can be "inside the monitor") • Synchronization is implemented using condition variables We use a monitor to synchronize accesses to the read and write actions.

Priority scheduling

A priority number (integer) is associated with each task • explicitly assigned by the programmer or • computed, through a function that depends on task properties e.g., memory use, timing: duration (estimated), deadline, period

Consider a multicore system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be greater than the number of processing cores in the system. Discuss the performance implications of the following scenarios. A. The number of kernel threads allocated to the program is less than the number of processing cores. B. The number of kernel threads allocated to the program is equal to the number of processing cores. C. The number of kernel threads allocated to the program is greater than the number of processing cores but less than the number of user-level threads.

A. Some processes will be idle because the scheduler can only map kernel threads to processors - not user level threads. B. All processors may be used at the same time but a kernel thread blocking inside the kernel could cause a processor to be idle. C. A blocked kernel thread here can be swapped for another that is available and ready

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

A. Stealing or copying one's programs or data; using system resources (CPU, memory, disk space) without proper accounting. B. Probably not, since any protection scheme devised by humans can inevitably be broken by a human, and the more complex the scheme the more difficult it is to feel confident of its correct implementation.

Direct memory access is used for high/speed I/O devices in order to avoid increasing CPU's execution load. A. How does the CPU interface with the device to coordinate transfer? B. How does the CPU know when the memory operations are complete? C. The CPU is allowed to execute other programs while the DMA controller is transferring data. Does this process interfere with the execution of the user programs? If so, describe what forms on interference are caused.

A. The CPU can initiate a DMA operation by writing values into special registers that can be independently accessed by the device. The device initiates the corresponding operation once it receives a command from the CPU. When the device is finished with its operation, it interrupts the CPU to indicate the completion of the operation. B. Both the device and the CPU can be acessing memory simultaneously. The memory controller provides access to the memory bus in a fair manner to there two entities. A CPU might therefore be unable to issue memry operations at peak speeds since it has to complere the device in order to obtain access to the mmeory bus.

Memory manager functional requirements

Abstraction − MM (virtually) appears to be larger than the physical machine mem. − Memory is presented as an array of contiguously addressed bytes − Abstract set of logical addresses to reference physical memory Allocation − Allocate primary memory to processes as requested• Isolation − Enable mutually exclusive use of memory by processes Memory Sharing − Enable memory to be shared by processes

Advantages/Disadvantages of an API to system calls

Advantage of an API to system calls + API works at a higher abstraction closer to programs need➔ easier to work with + API calls may combine many system calls to implement higher level tasks (e.g., copy a file) ➔ less calls needed + a program written using an API can compile/run on any system supporting the API ➔ portable Disadvantage of an API to system calls - Adds one more layer ➔ increased overhead

What is the main advantage of the microkernel approach to system design? How do user programs and system services interact in a microkernel architecture? What are the disadvantages of using the microkernel approach?

Advantages: + Adding a new service does not require modifying the kernel, + It is more secure as more operations are done in user mode than in kernel mode, and + A simpler kernel design and functionality typically results in a more reliable operating system. User programs and system services interact in microkernel architecture by using interprocess communication mechanisms such as messaging. These messages are conveyed bythe operating system. Disadvantages: - The primary disadvantages of the microkernel architecture are the overheads associated with inter process communication and the frequent use of the operating system's messaging functions in order to enable the user process and the system service to interact with eachother

Advantages of Single-programmed solution

Advantages: • simple hardware requirements (base address and limit registers) • Easy protection between OS and processes and between processes

Invariant

An assertion that holds at all control points of a program

What is the purpose of interrupts? What are the differences between trap and interrupt? Can traps be generated intentionally by a user program? If so, for what purpose?

An interrupt is a hardware-generated change of slow withing the system. An interrupt handler is summoned to deal with the cause of the inteerupt; control is then returned to the interrupted context and instruction. A trap is a software-generated interrupt. An interrupt can be used to signalthe completion of I/O to obviate the need for device polling. A trap can be used to call operating system rountined or to catch arithmetic erros.

Interrupt

An interrupt is a signal to the CPU that transfers control to an interrupt service routine • caused by external device (e.g. a result of clock tick, ready for i/o, i/o completion) • interrupt vector contains address of the service routine • OS preserves CPU state by storing registers and program counter (address of the interrupted instruction is saved)

Topology invariant

An invariant derived directly from the program code• Examples: • number of times an operation is executed in comparison to another action. • Value of a variable based on the number of times a set of actions was executed

Operating System (OS) + Advantages

An operating system is a piece of software that acts as an intermediary between users/applications and computer hardware. Advantages: - It provides a level of abstraction that hides the gory details of the HW architecture from applications. - It organizes sharing of HW resources among applications and users. - It optimizes performance through resource management.

Limitations of mutexes or semaphores

At any given time, we can have several readers but no writer, or one writer and no readers. (readers-writers problem)

Thread

• A dispatchable unit of work within a process • Threads within a process share code and data segments (i.e., share memory address space)

Memory management in early systems

• Every active process resides in its entirety in main memory - Large programs cannot execute • Every active process is allocated a contiguous part of main memory.

Consider a computing cluster consisting of two nodes running a database. Describe two ways in which the cluster software can manage access to the data on the disk. Discuss the benefits and disadvantages of each.

Consider the following two alternatives: asymmetric clustering and parallel clustering. With asymmetric clustering, one host becomes the active server. This is appropriate for providing redundancy. However, it does not utilize the potential processing power of both hosts. With parallel clustering, the database application can run in parallel on both hosts. The difficulty in implementing parallel clusters is providing some form of distributed locking mechanism for filler on the shared disk.

Context switch:

Context switch: Saving the state of a process whose execution is to be suspended, and reloading this state when the process is to be resumed.

Scheduling

Decide what (executes/is loaded/has access to) where and when: Examples: • Processor scheduling: decide which task (thread/process) executes on each core at every given time. • Memory scheduling: decide which memory page of a process is loaded in each page frame of the main memory at every given time. Decision mode defines when scheduling decisions are taken: • Preemptive vs non-preemptive • Periodic/time-based vs event-based

Earliest Deadline First (EDF)

Decision mode: preemptive Priority function: least time remaining until absolute deadline → higher priority Arbitration rule: chronological or random ordering

Rate Monotonic (RM) Scheduling

Decision mode: preemptive Priority function: shorter period T → higher priority Arbitration rule: chronological or random ordering

Deadline Monotonic (DM) Scheduling

Decision mode: preemptive Priority function: shorter relative deadline D→ higher priority Arbitration rule: chronological or random ordering

Round Robin (RR) scheduling

Each task gets a small unit of CPU time (time quantum of length q) (At the end of a time quantum, the task is preempted and is added to the end of the ready queue.) • Decision mode: if a task runs q continuous time units, it is preempted • Priority function: the earliest it is added to the ready queue, the higher the priority • Arbitration rule: random ordering Typically, higher average turnaround than SJF, but better response time

One-to-one Multithreading model

Each user-level thread maps to a kernel thread Advantage: allows for concurrency between thread • Disadvantage: the kernel must manage all threads (state, schedule, ...) • Low performance in case of many user threads

Disadvantages of virtual memory

Disadvantages: - Increased processor hardware costs - Increased overhead for handling page faults - Increased software complexity to prevent thrashing

Disadvantages of threads

Downside: no protection against other threads (faults, memory sharing)

OS: Dual-mode operation

Dual-mode allows the OS to protect itself and other system components. Different privileges required for different types of code • Most instructions (user code) can be executed in user mode − In user mode CPU cannot access memory locations reserved for OS • Some "privileged" instructions are only executable in kernel mode Mode bit provided by hardware − Provides ability to distinguish when system is running user code or kernel code. − A system call changes the execution mode to kernel mode, returning from the system call resets the mode to user mode.

What of the following components of program state are shared accross threads in a multithreaded process? a. Register values b. Heap memory c. Global varibles d. Stack memory

Heap memory and global variables. Each thread has its separate set of register values and a separate stack.

Transparency

Hide details with respect to a given issue. Examples: • processor architecture (Instruction Set Architecture - ISA) − mechanism: use compiler • physical memory size − mechanism: virtual memory i.e., present linear memory model that is larger than physical • Location of programme and data in physical memory − mechanism: indirection using logical memory address

Describe the actions taken by a kernel to context-switch between processes.

In general, the operating system must sabe the state of the current running process and restore the state of process scheduled to be run next. Saving the state of a process typically includes values of all the CPU registers in additional memory allocation. Context switches must also perform many architecture-specific operations, including flushing data and instruction caches.

Resource dependency graph (Reusable resources and action synchronizations)

Resource dependency graph: • bipartite graph with two classes of nodes = tasks and resources • three types of edges: − Type1: task has requested and now waits for the resource − Type2: resource acquired (held) by task − Type3: task may request the resource • A resource dependency graph represents a particular state of the system

Advantages of threads

Increase concurrency level (less costly than by using processes): • Better performance − hide latency (while waiting CPU can do something useful in another thread) − increase responsiveness (divide work) − exploit platform parallelism (multiple processors → multiple threads) Use "natural" concurrency within a program : • natural organization, structure, e.g. − one thread per event − one thread per task − one thread per resource − one thread to handle each user interface

Atomic Action

Indivisible step in the evolution of an executed program

Explain the difference between internal and external fragmentation.

Internal fragmentation is the area in a region or a page that is not used bt the job occupying that region or page. This space is unavailable for use by the system until that job is finished and the page or region is released. External fragmentation is unused space between allocated regions of memory. Typically external fragmentation results in memory regions that are too small to satisfy a memory request, but if we were to combine all the regions of external fragmentation, we would have enough memory to satisfy a memory request.

Detection (during execution)

Invoke detection algorithm periodically to check if deadlock occurs You need • an algorithm to examine the state upon execution of a blocking action • an algorithm to recover from a deadlock Repeatedly monitoring and potentially recovering causes large overheads

lightweight process (LWP)

Lightweight process (LWP) as a user-level representation of a kernel thread • LWP an intermediate data structure • like a virtual processor for user the threads and thread library User thread library schedules user threads on LWPs and Kernel schedules LWPs.

Direct Memory Access (DMA) + Advantages

Main memory access by a controller over the bus. Advantages: • Less operations executed by the CPU • Less interrupts to treat • CPU can execute other useful code in parallel

Why is the separation of mechanism and policy desirable?

Mechanism and policy must be separate to ensure that systems are easy to modify. No two system installations are the same, so each installation may wary to ture the operating system to suit its needs. With mechanism and policy seprate, the policy might be changed while mechanism stays unchanged.

Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on a single-processor system?

No. A multi-threaded system consists of multiple user-level threads that cannot make use of the different processors in a multiprocessor system concurrently. The operating system perceives only a single process and will not schedule the different threads of the process on separate processors.

In Chapter 3, we discussed Google's Chrome browser and its practice of opening each new website in a separate process. Would the same benefits have been achieved if instead Chrome had been designed to open each new website in a separate thread? Explain.

No. The primary reasong for opening each website in a seprate process is that if a web application in one website crashes, only that render process is affected, and the browser process as well as other renderer processes, are unaffected. If you use a thread for each webpage, then if a webpage crashes, it will bring down the whole application.

Semaphores

Non-negative integer s with initial value s0 and atomic operations P(s) and V(s). P(s): < await(s>0); s := s-1 > →the task sleeps until 's>0' holds, decrement s V(s): < s := s+1 > →increment s Note: the notations P(s) and V(s), and lock(s) and unlock(s) interchangeably when s is a mutex (i.e., a binary semaphore). Semaphores can be used to implement mutual exclusion.

Process v.s. Thread

Process: • defines a memory space • defines ownership on other resources • has at least one associated thread of execution • Context of execution saved in a PCB Thread: • all threads of a process can operate in their process' address space (several threads may share the same variables) • has an associated execution state (PCB is extended with thread info) - program counter, stack image, return addresses of function calls, values of processor registers

Deadlock Conditions

Program behaviors that may lead to deadlock • mutual exclusion • greediness: hold and wait − incrementally reserving some resources while waiting for other resources to become available (e.g., dining philosophers). • absence of preemption mechanism • circular waiting− e.g., tasks tA, tB and tC waiting on each other:

Virtualization

Provides a simple, abstract, logical model of the system • virtual memory, virtual CPU, virtual disk. • Program can be developed as if they were the sole user of the HW resources. Current systems tend to virtualize the entire hardware • i.e., it yields a virtual machine Virtualization can also help support several guest OS's on top of one host OS or on top of a given platform • Implemented on a run-time virtualization layer

Busy-waiting

Repeated testing without going to sleep Acceptable only when: • waiting is guaranteed to be short or • there is nothing else to do (e.g., when the task executes on dedicated hardware) Busy-waiting using await() works only if • the tests using await and locking the mutex are executed atomically(usually not possible) Alternative: use semaphores for actions synchronization

Shortest-Job-First (SJF) scheduling

Schedule the task with the shortest next CPU burst. • Decision mode: non-preemptive • Priority function: equal to -L where L is the length of the next CPU burst • Arbitration rule: chronological or random ordering + SJF is optimal. • gives minimum average waiting time for a given set of tasks... if you know their execution time - Problem • needs prediction of the next CPU burst length e.g. by using exponential weighted average of bursts in the past (see in the textbook)

First-Come, First-Served (FCFS) scheduling

Schedule the tasks in order of their arrival. • Decision mode: non-preemptive • Priority function: the earlier the arrival, the higher the priority • Arbitration rule: random choice among processes that arrive at the same time

Shared variables/Private variables/Atomic action/Concurrent execution/Race condition

Shared variables: accessible to several tasks (processes/threads) Private variables: accessible only to a single task Atomic action: finest grain of detail, indivisible • typically, assignments and tests in a program • sufficient at program level: single reference to shared variable in statement− ignoring possible optimization and reordering by compiler/processor Concurrent execution: interleaving of atomic actions• Interference: disturbing others' assumptions about the state• usually, caused by "bad" interleavings • particularly with shared variables Race condition: situation in which correctness depends on the execution order of concurrent activities ("bad interference")

Disadvantage of Priority scheduling

Starvation - low priority processes may never execute.

Switching between threads

Switching between threads: two possibilities • switching as a kernel activity − kernel maintains execution state of thread − similar to process switching • switching handled by user -level thread package (library) − the package maintains execution state of threads (kernel knows kernel threads only) − the package must obtain control in order to switch threads − responsibility of programmer to call package - 'cooperative multithreading'

Many to One Multithreading Model

User threads mapped to single kernel thread Advantage: Thread management by thread lib • no need for kernel involvement, ➔ fast ➔ easy to deploy Disadvantage: Only one user thread can access the kernel at a given time • multiple threads cannot run in parallel on different processors • a blocking system call from one user thread blocks all user threads of the process

Process control block (PCB)

The PCB records information associated with a process context of execution: • Process state - running, waiting, etc. • Program counter - location of next instruction to execute • CPU registers - contents of all process-centric registers • CPU scheduling information- priorities, scheduling queue pointers • Memory-management information - memory allocated to the process • Accounting information - CPU used, clock time elapsed since start, time limits • I/O status information - I/O devices allocated to process, list of open files T

Process

• It is a program in execution. • It has a context of execution • A process owns resources (has memory and can own other resources such as files, etc.) • Several processes can run the same program (they all have a different context of execution)

Wait-for graph (Consumable resources and condition synchronizations)

The graph captures a possible dynamic situation (reachable system state) • We must prove the possibility of existence of the graph − e.g., if a is always negative, there is never a state with an arrow p2 → p3 • We label the edges with corresponding blocking conditions − i.e., information about the state that gives the specific blocking− e.g., at this state p3 is blocked due to x<0 and p4 is blocked due to ¬b

Consider the following process for generating binaries. A compiler is used to generate the object code for individual modules, and a linkage editor is used to combine multiple object modules into a single program binary. How does the linkage editor change the binding of instructions and data to memory addresses? What information needs to be passed from the compiler to the linkage editor to facilitate the memory-binding tasks of the linkage editor?

The linkage editor has to replace unresolved symbolic addresses with the actual addresses associated with the variables in the final program binary. In order to perform this, the modules should keep track of instructions that refer to unresolved symbols. During linking, each module is assigned a sequence of addresses in the overall program binary andwhen this has been performed, unresolved references to symbols exported by this binary could be patched in other modules since every other module would contain the list of instructions that need to be patched.

It is sometimes difficult to achieve a layered approach if two components of the operating system are dependent on each other. Identify a scenario in which it is unclear how to layer two system components that require tight coupling of their functionalities.

The virtual memory subsystem and the storage subsystem are typically tightly coupled and requires careful design in a layered system due to the following interactions. Many systems allow files to be mapped into the virtual memory space of an executing process. On the other hand, the virtual memory subsystem typically uses the storage system to provide the backing store for pages that donot currently reside in memory. Also, updates to the file system are sometimes buffered in physical memory before it is flushed to disk, thereby requiring careful coordination of the usage of memory between the virtual memory subsystem and the file system.

Deadlock

When a set of tasks is blocked indefinitely and cannot make progress anymore

Competition →Mutual exclusion

• N concurrent processes competing for a resource • Tasks define critical sections (CS) • Introduce extra synchronization requirements to access the CS.

Reasons why threads operate faster than processes

Threads operate faster than processes due to the following reasons: • Thread creation and termination is much faster (no memory address space copy needed) • Context switching between threads of the same process is much faster (no need to switch the whole address space) • Communication between threads is faster and more at the programmer's hand than between processes (shared address space)

Approaches to dealing with deadlocks

Three active approaches to dealing with deadlocks: 1. Prevention (programmer side)− at design time 2. Avoidance (system side)− dynamicly checks to avoid entering risky states (can be expensive) 3. Detection and recovery− checks only whether we are in a deadlock state or not, and try to recover from it

Concurrent Trace

Trace made of an interleaving of atomic actions of two or more tasks

Types of system calls

Types of system calls: • Process management − create, destroy, communication, synchronization, ... • File management − open, close, read, write, ... • Memory management − allocation, free, virtual memory, ... • Device management − access control, open, attach, send/receive, .... • Communications − setup communications, exchange messages, .... • Miscellaneous − timers, inspect system resources, ...

Deadlock Avoidance (during execution)

Upon executing each potentially blocking action (e.g., P(m)): • check if an open execution path exists (system remains in a "safe" state) • otherwise, deny or postpone the action Existence of an open path = reduced dependency graph is empty Postponing works if the blocking actions refer to allocations of reusable resources and we can compute all possible future states Example of such algorithm: the banker's algorithm

Deadlock Prevention (at design time)

Use reduced dependency graphs and wait-for graphs at design time • make the reduced dependency graphs empty by construction • prevent cycles in the wait-for graphs Use synchronization tricks (see "actions synchronization") • Examples: − no circular wait, − ensure terminating critical sections − Acquire "all resources at once", i.e., avoids the "wait-and-hold" greediness • not always possible Allow preemption of resources when needed • Examples: add timeout on how long a task can hold a resource, or allow a task to steal a resource from another one • not always possible (e.g., an I/O device may be in an inconsistent state if preempted during an I/O operation)

Actions synchronization

Uses semaphores to synchronizes actions in different tasks to enforce new invariants (called synchronization invariants or synchronization conditions)

Advantages of Process

Using processes allows to use platform parallelism (Example: if the processor has more than one core, two or more different process can make simultaneous progress) + It also allows for concurrency (The same resource (e.g., a core or network driver) can be time shared ➔ improve responsiveness) + If a process is waiting (e.g., to get access to a resource, or to receive data from another process), then the kernel can schedule another process ➔ more efficient use of the system resources

Under what circumstances would a user be better off using a timesharing system rather than a PC or a single-user workstation?

When there are few other users, task is large, and the hardware is fast, time -sharing makes sense.

Is it possible to have concurrency but no parallelism? Explain.

Yes. Concurrency means is a condition exists that more than one process as well as thread is progressing at the same time. However, it does not imply that the processes are running simultaneously. The scheduling of tasks allows for concurrency, but the parallelism is supported only on the systems with more than one processing core.

Cooperation →Synchronization

• N concurrent processes working for a common goal • Goal 1: avoid program traces that may violate a certain invariant • Goal 2: steer the execution to maintain some property− e.g., enforce an execution order • Typically, by blocking the task execution until an assertion becomes true

Fixed partitioning scheme

• Partitions have fixed size • Processes are assigned to a free partition that is big enough • Number of active processes limited by number of partitions • Size of processes limited by the size of the largest partition • Wastes memory due to internal fragmentation

Dynamic partitioning scheme

• Processes are dynamically allocated space in main memory • Number of active processes is only limited by the size of the memory • Size of a process is limited by the size of the memory • Wastes memory due to external fragmentation

Single-programmed solution

• Program loaded in its entirety into MM and allocated as much contiguous MM space as needed • Once in MM, program stays there until execution ends.

Signal vs. Sigall

• Requires a careful analysis to ensure both correctness and efficiency. • Sigall is always correct, but often inefficient.

Relocatable partitioning scheme

• Same as dynamic, but can compact memory to make space for more processes • Compaction is a costly operation • Requires dynamic address binding

Trace

• Sequence of atomic actions in the execution of a program • Typically, a sequence of assignments and tests

Portability

• a program written using an OS or an API can compile/run on any system supporting that OS or API • Protect investments in application software - Reduces cost to support several platforms - Reduces cost to upgrade/change the execution platform - Simplifies integration of several application components • OS gives a unified machine view to applications, effectively defining a virtual machine


Conjuntos de estudio relacionados

Abeka 5th Grade History Chapter 14 Check Up Section F

View Set

PowerPoint Chapter 2 True and False

View Set

Marketing Chapter 8 - Distribution

View Set

Chapter 8-14 Final Exam Psychology

View Set