期末复习 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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,080评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,422评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,630评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,554评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,662评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,856评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,014评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,752评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,212评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,541评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,687评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,347评论 4 331
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,973评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,777评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,006评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,406评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,576评论 2 349

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,312评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,437评论 0 23
  • The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...
    网事_79a3阅读 11,956评论 3 20
  • 2017年暑假,我认识了他。他对我来说很遥远。而深深吸引我的是对人对事的态度。他说他是一个问题小孩。他说他叛逆。他...
    Wink鐽阅读 1,705评论 0 1
  • 今天看的视频是一个大学生演讲的,语言的力量。可能她说的没有其他科学家说的那么有科学数据作为理论依据,和各种数学知识...
    淡墨非痕阅读 184评论 0 0