期末复习 Operating Systems

Q1

1. An operating system is the most important software that runs on a computer and provides

services to applications. It manages the computer's memory, processes, and all of its

software and hardware. It also allows a user to communicate with the computer without

knowing how to speak the computer's language and its details.

• The computer can be a networked system with many servers

• It hides the “messy” details using a level of abstraction

• It presents the user with a simplified machine, much easier to use

• It executes user’s programs on a specific platform

• It uses the computer hardware and resources efficiently

2. Client obtains service by sending messages to server processes through microkernel.

Benefits

• Uniform interface on request made by a process

all services are provided by means of message passing (through the microkernel)

• Extensibility

allows the addition of new services

• Portability/Maintainability

changes needed to port the system to a new processor are made within the microkernel -

not in the other services

Weakness

In a micro kernel architecture applications communicate with service via the kernels interprocess communication channels. As Operating System services execute in user space the

kernel must perform multiple context switches in order to service the request. In the

monolithic kernel architecture, the core services are implemented in the kernel, no context

switch is required (only an escalation of privilege). Due to this micro kernels are often slower

compared to monolithic kernels, i.e. less efficient


3.

• External fragmentation occurs when holes appear in

otherwise contiguous memory blocks

• Internal fragmentation occurs when the block of memory

allocated to a process is larger than the memory that process

requires

4.

(1)First fit:

A:9-12

B:1

(2)Best fit:

A:15-18

B:1

(3)Worst fit:

A:9-12

B:15

5.

Advantages:

1.Cheaper in large disk subsystems, RAID1 need as twice as many disks are needed to store

data.

2. Good general performance

Disadvantages:

1. RAID1 has better security as it provide a redundancy of all data.

2. Need additional CPU performance to calculate parity

6.

Limited power in processor

Limited Space

Q2

a.(1)

fork() creates a new process

• Requires no arguments, returns identifier of child process

• Creates an exact copy of the parents address space for new process.

• Child process continues executing from where the fork() call was made in the parent

process

• Returns zero to the newly created child process

(2)

pipe() creates a pipe, a unidirectional data channel that can be used for interprocess

communication. The array pipefd is used to return two file descriptors referring to the ends

of the pipe. pipefd[0] refers to the read end of the pipe. pipefd[1] refers to the write end of

the pipe. Data written to the write end of the pipe is buffered by the kernel until it is read

from the read end of the pipe.

(3)

0

After the fork function, the child process and the parent process use separate addresses in

memory, and changes to the parameters in the child process do not affect the parent process.

(4)

0 1 2 3 4

b.

What are threads?

• Multiple concurrent paths of execution within process

• Lightweight process

• Unit of dispatching (execution)

• Threads in a process share address space

• Separate concurrency from protection

Why use multithreading?

Primary Benefits

• Responsiveness : applications can continue executing while parts are blocked

• Resource sharing : Threads share code and data

• Economy : Cheaper to create threads than processes

• Multiprocessor utilisation : threads can utilise parallel execution

Separates resource ownership and scheduling

• Multithreading is rarely used without requiring some access to shared resources

Application threads must map to a kernel execution thread

• User level : Many to one mapping

• Kernel level : One to One mapping

User level threads

Threads exist only in user space, kernel knows nothing about them

• Require a runtime package to implement the threads and keep track of them

• Can be used on systems that do not support threading


Benefits

• Cheap to create

• Cheap context switches

• Thread yields don’t result in process context switch

• Application specific scheduling

Drawbacks

• Blocking system calls can block entire process

• Errors propagate to whole process

• No clock interrupts, scheduler runs at same level

as thread

• No benefits from multi-processor systems

Kernel level threads

Kernel has full knowledge of all threads and processes

• A kernel thread is created for each user thread

• Requires specific kernel support

Benefits

• Kernel has full control of thread scheduling.

May give more time to processes with more

threads.

• Errors stop threads not processes

• Kernel handles blocking system calls

Drawbacks

• Operations much slower than user level

threads

• Significant overhead for kernel. It must

manage and schedule processes and threads.

c.

HOW

the output is dependent on the sequence or timing of other uncontrollable events. It becomes

a bug when events do not happen in the order the programmer intended.

Results:

Execution may fail sporadically and with strange, unreproducible output

Solving requires mutual exclusion

• Ensure only one process or thread can do the same thing to a shared variable or file

• Access to shared resources must be synchronised to avoid inconsistencies

Critical Section

Part of a cooperating processes (or threads) where a shared

resource is accessed and must be executed atomically

Problem solution requires:

•Mutual exclusion: No two processes or threads can be in their related

critical sections at the same time

•Progress: Progress cannot be delayed by another process or thread not

in a critical section

•Bounded Waiting: No process or threads should wait forever to enter its

critical section

MapReduce

Long Tail phenomena

Possible mitigation strategy:

Monitoring

Scheduling: Load Balancing

Fault-tolerance

你可能感兴趣的:(期末复习 Operating Systems)