亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? homework #2 solution.htm

?? operating system concepts sixth edition windows XP updat 操作系統課后答案
?? HTM
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0059)http://www.cse.ucsd.edu/classes/fa04/cse120/hw/hw2-sol.html -->
<HTML><HEAD><TITLE>CSE 120 (Fall 2004) -- Homework #2 Solution</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY>
<H2>CSE 120 (Fall 2004) -- Homework #2 Solution</H2><FONT color=blue 
size=+1><B>Out: 10/12</B></FONT><BR><FONT color=red size=+1><B>Due: 
10/26</B></FONT> 
<OL>
  <LI>Chapter 4: 4.3 
  <P>4.3&nbsp; A DECSYSTEM-20 computer has multiple register sets. Describe the 
  actions of a context switch if the new context is already loaded into one of 
  the register sets. What else must happen if the new context is in memory 
  rather in a register set, and all of the register sets are in use? <I>
  <P>If the new context is already in one of the register sets, the kernel 
  switches the active register set to it. Otherwise the kernel will use some 
  cache replacement algorithm to replace the new context with the some existing 
  sets in one of the register sets, saving an active set to memory and restoring 
  the needed set from memory. </I>
  <P></P>
  <LI>Chapter 5: 5.1, 5.2, 5.3 
  <P>5.1&nbsp; Provide two programming examples of multithreading that improve 
  performance over a single-threaded solution. <I>
  <P>Programs that have high parallelism - multithreading kernel on 
  multiprocessors, parallel scientific computations, etc. 
  <P>Programs that share lots resources between different internal entities - 
  web browsers, web servers, database access, online multi-user games. 
  <P>Programs that easier to program/structure/debug in multithreading model - 
  network servers, GUI systems. </I>
  <P>5.2&nbsp; Provide two programming examples of multithreading that do not 
  improve performance over a single-threaded solution. <I>
  <P>Programs that require sequential processing - Shell programs, printer 
  driver. 
  <P>Simple Programs - Hello world, embedded programs running on simple 
  hardware/chips. </I>
  <P>5.3&nbsp; What are the differences between user-level threads and 
  kernel-level threads? Under what circumstances is one type better than the 
  other? 
  <P>Lecture 5 Slides 12-18 cover all the details. </I>
  <P></P>
  <LI>Chapter 6: 6.8, 6.10 
  <P>6.8&nbsp; Many CPU scheduling algorithms are parameterized. For example, 
  the RR algorithm requires a parameter to indicate the time slice. Multilevel 
  feedback queues require parameters to definite the number of queues, the 
  scheduling algorithms for each queue, the criteria used to move processes 
  between queues, etc. These algorithms are thus really sets of algorithms 
  (e.g., the set of RR algorithms for all time slices, etc.). One set of 
  algorithms may include another (in lecture, we talked about using Priority 
  Scheduling to implement SJF). What, if any, relation holds between the 
  following pair of algorithms? <I>
  <P>a. Multilevel feedback queue and RR - RR is implemented, by default, as the 
  general scheduling algorithm for the individual queues of MFQ. Each job in a 
  particular priority queue is dispatched in an RR fashion. 
  <P>b. Multilevel feedback queue and FCFS - The jobs in the individual queues 
  of the MFQ can be scheduled in FCFS fashion by the dispatcher. 
  <P>c. Priority and FCFS - In FCFS, priority is assigned to the incoming jobs 
  based on their individual times of arrival. The older a job is, the higher is 
  its priority. Thus, FCFS is a sort of Priority scheduling, where priority is 
  based on the time parameter 
  <P>d. RR and SJF - Not related under usual circumstances since RR pays no 
  attention to the total CPU burst of a job while SJF relies solely on this 
  property to schedule the waiting jobs. </I>
  <P>6.10&nbsp; Explain the differences in the degree to which the following 
  scheduling algorithms discriminate in favor of short processes: <I>
  <P>a. FCFS - FCFS does not favor short processes at all, it only cares about 
  the process arrival time. 
  <P>b. RR - RR favors short processes that they finish earlier than long 
  processes that arrive at almost same time. 
  <P>c. Multilevel feedback queues MFQ moves a processes to lower-priority level 
  queue if it consumes too much cpu cycles. Hence it favors short processes more 
  than RR algorithms. </I>
  <P></P>
  <LI>Chapter 7: 7.8, 7.9, 7.13 
  <P>7.8&nbsp; <B>The Sleeping-Barber Problem.</B> A barbershop consists of a 
  waiting room with n chairs and the barber room containing the barber chair. If 
  there are no customers to be served, the barber goes to sleep. If a customer 
  enters the barbershop and all chairs are occupied, then the customer leaves 
  the shop. If the barber is busy but chairs are available, then the customer 
  sits in one of the free chairs. If the barber is asleep, the customer wakes up 
  the barber. Write a program to coordinate the barber and the customers. <I>
  <P><A 
  href="http://www.cse.ucsd.edu/classes/fa04/cse120/hw/sleeping_barber.c">sleeping_barber.c</A> 
  </I>
  <P>7.9&nbsp; <B>The Cigarette-Smokers Problem.</B> Consider a system with 
  three smoker processes and one agent process. Each smoker continuously rolls a 
  cigarette and then smokes it. But to roll and smoke a cigarette, the smoker 
  needs three ingredients: tobacco, paper, and matches. One of the smoker 
  processes has paper, another has tobacco, and the third has matches. The agent 
  has an infinite supply of all three materials. The agent places two of the 
  ingredients on the table. The smoker who has the remaining ingredient then 
  makes and smokes a cigarette, signaling the agent on completion. The agent 
  then puts out another two of the three ingredients, and the cycle repeats. 
  Write a program to synchronize the agent and the smokers. <I>
  <P><A 
  href="http://www.cse.ucsd.edu/classes/fa04/cse120/hw/cigarette_smokers.c">cigarette_smokers.c</A> 
  </I>
  <P>7.13&nbsp; Suppose that the signal statement can appear only as the last 
  statement in a monitor procedure. Suggest how the implementation described in 
  Section 7.7 can be simplified. <I>
  <P>The textbook implements Hoare monitors. When a thread T1 calls signal(), 
  the control switches to another thread T2 that is waiting for the condition 
  immediately. In Hoare's implementation, when T2 leaves the monitor or calls 
  another wait(), the control should be switched back to T1,&nbsp; not to the 
  other threads that are waiting to get into the monitor. Since T1 is still 
  inside the monitor, although it is inactive now, it would be better to let T1 
  finish its work first than admit the others into the monitor. The <FONT 
  face="Courier New" size=2>next</FONT> semaphore and the <FONT 
  face="Courier New" size=2>next_count</FONT> variable are used to keep track of 
  this situation. 
  <P>If <FONT face="Courier New" size=2>signal()</FONT> is the last statement of 
  every monitor procedure, we are ensured that T1 is no longer in the monitor 
  and therefore we do not need <FONT face="Courier&#10;New" size=2>next</FONT> 
  semaphore and the <FONT face="Courier New" size=2>next_count</FONT> variable 
  anymore. <!-- This is actually theimplementation of the Hansen/MESA monitor. <PRE>sem_wait(mutex); F()sem_signal(mutex); </PRE><PRE>class condvar { int count = 0; semaphormutex; semaphor x_sem;  condvar() {    count = 0;    sem_init(&amp;mutex, 1);    sem_init(&amp;x_sem, 0);  }  wait() {    count++;    sem_signal(mutex);    sem_wait(x_sem);    count--;  }    signal() {    if (count &gt; 0)    	signal(x_sem);  }}</pre>--></I>
  <P></P>
  <LI>Chapter 8: 8.4 
  <P>8.4&nbsp; Consider the traffic deadlock depicted in Figure 8.8 (see book). 
  <I>
  <P>a. Show that the four necessary conditions for deadlock indeed hold in this 
  example.<BR>
  <P>
  <OL>Process - vehicle, Resource - road 
    <LI>Mutual Exclusion - the one lane road can accommodate one vehicle in 
    parallel 
    <LI>Hold and wait - a vehicles is occupying some road space and is waiting 
    for more to move. 
    <LI>No Preemption - can't remove vehicle if it is on the road 
    <LI>Circular wait - number the cars. car 0 is waiting for car1, car1 is 
    waiting for car2, ..., car N is waiting for car 0. </LI></OL>
  <P>b. State a simple rule that will avoid deadlocks in this system.<BR>
  <P>Do not block - make sure you can safely pass the crossroad before you move 
  forward. </I><!--<P>Common Mistakes: Only intersection/crossroad cases are not complete   answers. If we allow two cars to stay in one lane, or we can blow out cars in   the road, the deadlock is unlocked. Traffic light is neither a good solution   to avoid deadlock, the deadlock in the figure might be generated when there   are traffic lights. (Try to put traffic lights in the figure) -->
  <P></P>
  <LI>The Intel x86 instruction set architecture provides an atomic instruction 
  called XCHG for implementing synchronization primitives. Semantically, XCHG 
  works as follows (although keep in mind it is executed atomically): 
  <BLOCKQUOTE><PRE>void XCHG(bool *X, bool *Y) {
  bool tmp = *X;
  *X = *Y;
  *Y = tmp;
}
</PRE></BLOCKQUOTE>
  <P>Show how XCHG can be used instead of test-and-set to implement the 
  acquire() and release() functions of the lock data structure described in the 
  "Synchronization" lecture. <I>
  <BLOCKQUOTE><PRE>struct lock {
  bool isAvailable = TRUE;
}

void acquire (struct lock * p_lock) {
  bool isAvailable = FALSE;
  while(!isAvailable)
    XCHG(&amp;(p_lock-&gt;isAvailable), &amp;isAvailable); 
}

void release (struct lock * p_lock) {
  p_lock-&gt;isAvailable = TRUE;
}
</PRE></BLOCKQUOTE></I><!--  Common Mistakes: use two variables in lock structure and swap them to   implement <font face="Courier New" size="2">acquire()</font> and  <font face="Courier New" size="2">release()</font>, this usually results to   dangerous code because there might be context switches between XCHG and while   statements.-->
  <LI>A common pattern in parallel scientific programs is to have a set of 
  threads do a computation in a sequence of phases. In each phase <I>i</I>, all 
  threads must finish phase <I>i</I> before any thread starts computing phase 
  <I>i+1</I>. One way to accomplish this is with barrier synchronization. At the 
  end of each phase, each thread executes <I>Barrier::Done(n)</I>, where 
  <I>n</I> is the number of threads in the computation. A call to 
  <I>Barrier::Done</I> blocks until all of the <I>n</I> threads have called 
  <I>Barrier::Done</I>. Then, all threads proceed. <I>
  <P>a. Write a monitor that implements Barrier using Mesa semantics. 
  <BLOCKQUOTE><PRE>monitor Barrier {
  int called = 0;
  condition barrier;

  void Done (int needed) {
    called++;
    if (called == needed) {
      called = 0;
      barrier.broadcast();
    } else {
      barrier.wait();
    }
  }
}
</PRE></BLOCKQUOTE>
  <P>b. Implement Barrier using an explicit mutex and condition variable. The 
  mutex and condition variable have the semantics described at the end of the 
  "Semaphore and Monitor" lecture in the ping_pong example, and as implemented 
  by you in Project 1. 
  <BLOCKQUOTE><PRE>class Barrier {
  int called = 0;
  Lock mutex;
  Condition barrier;

  void Done (int n) {
    mutex.Acquire();

    called++;
    if (called == needed) {
      called = 0;
      barrier.Broadcast(&amp;mutex);
    } else {
      barrier.Wait(&amp;mutex);
    }

    mutex.Release();
  }
}
</PRE></BLOCKQUOTE></LI></OL><PRE>
</PRE>
<HR>

<ADDRESS><A href="mailto:voelker@cs.ucsd.edu">voelker@cs.ucsd.edu</A> 
</ADDRESS></I></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情综合在线| 91香蕉视频黄| 福利电影一区二区| 北条麻妃一区二区三区| 国产精品第13页| 亚洲最大色网站| 免费人成在线不卡| 成人激情图片网| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 91片在线免费观看| 制服丝袜在线91| 欧美—级在线免费片| 亚洲一区在线看| 国产综合久久久久久鬼色 | 中文字幕亚洲不卡| 亚洲激情图片小说视频| 久久se这里有精品| 91视频精品在这里| 日韩免费视频一区| 亚洲欧美色一区| 久久国产麻豆精品| 一本高清dvd不卡在线观看 | 国产一区二区三区不卡在线观看| eeuss鲁片一区二区三区在线观看| 在线电影一区二区三区| 国产人妖乱国产精品人妖| 亚洲综合在线免费观看| 国产中文字幕精品| 欧美日韩激情一区二区| 国产精品欧美一区喷水| 美女看a上一区| 色婷婷av一区二区三区软件| 2020国产精品| 午夜精品久久久久久久99樱桃| 亚洲精品一区二区三区99| 亚洲一区二区视频在线观看| 国产一区二区久久| 欧美日韩成人一区二区| 3atv一区二区三区| 免费在线观看视频一区| 国产精品91xxx| 国产91精品一区二区麻豆网站| 欧美写真视频网站| 欧美国产成人在线| 美女视频一区在线观看| 欧美影片第一页| 国产精品拍天天在线| 国模少妇一区二区三区| 欧美精品在线视频| 一区二区三区中文字幕| 成人深夜福利app| 久久久亚洲国产美女国产盗摄 | 色偷偷88欧美精品久久久| 久久精品无码一区二区三区| 免费在线看成人av| 欧美日韩一区中文字幕| 亚洲免费观看高清完整版在线观看熊| 国产精品一区二区你懂的| 日韩女优毛片在线| 奇米综合一区二区三区精品视频 | 亚洲一区二区三区四区五区黄| 国产91清纯白嫩初高中在线观看 | 一区在线观看免费| 久久99精品久久久久久久久久久久| 欧美视频精品在线观看| 亚洲黄一区二区三区| jlzzjlzz欧美大全| 国产精品资源在线| 久久综合色婷婷| 美女精品一区二区| 精品区一区二区| 久久成人免费网站| 精品国产乱码久久久久久久久| 老色鬼精品视频在线观看播放| 欧美一区二区三区精品| 青青草原综合久久大伊人精品优势| 欧美日韩精品三区| 天堂一区二区在线| 8x福利精品第一导航| 日韩综合小视频| 日韩三级视频在线观看| 看电视剧不卡顿的网站| 精品成人一区二区| 国产一区二区三区美女| 欧美激情一区二区三区在线| 成人禁用看黄a在线| 一区在线观看免费| 欧美日韩一区高清| 日韩福利视频网| 精品国精品自拍自在线| 国产精品资源网站| 国产精品盗摄一区二区三区| 欧美激情在线一区二区| 日韩理论片网站| 国产精品亚洲一区二区三区妖精| 久久精品一区四区| www.成人在线| 夜夜亚洲天天久久| 欧美肥胖老妇做爰| 捆绑紧缚一区二区三区视频 | 国产精品自拍在线| 国产精品久久久久久一区二区三区| 91麻豆免费看| 天堂一区二区在线| 久久你懂得1024| 91丨porny丨国产入口| 亚洲一区二区三区四区的| 欧美剧情电影在线观看完整版免费励志电影| 香蕉乱码成人久久天堂爱免费| 精品乱人伦小说| www.日韩av| 五月激情丁香一区二区三区| 久久综合成人精品亚洲另类欧美| 播五月开心婷婷综合| 五月天国产精品| 久久国产乱子精品免费女| 中文字幕一区二区三区视频| 欧美人伦禁忌dvd放荡欲情| 激情综合网av| 亚洲另类在线一区| 日韩一区二区三区免费观看| 高清免费成人av| 亚洲成人综合网站| 国内久久精品视频| 国产成人av一区二区三区在线| 国产精品一二三区| 日韩毛片视频在线看| 在线播放国产精品二区一二区四区 | 亚洲精品国久久99热| 日韩三级免费观看| 99久久国产免费看| 美美哒免费高清在线观看视频一区二区| 国产农村妇女毛片精品久久麻豆| 欧美伊人久久久久久午夜久久久久| 激情五月婷婷综合| 亚洲电影在线免费观看| 国产亚洲综合性久久久影院| 欧美日韩在线免费视频| 成人午夜又粗又硬又大| 青青草原综合久久大伊人精品优势| 中文字幕一区av| 久久综合九色综合欧美就去吻| 在线一区二区三区做爰视频网站| 国内成人精品2018免费看| 偷窥国产亚洲免费视频| 中国色在线观看另类| 精品免费视频一区二区| 在线影视一区二区三区| 国产成人午夜99999| 免费欧美日韩国产三级电影| 亚洲日本中文字幕区| 久久久久久久久免费| 欧美日韩一区不卡| 99久久精品国产毛片| 日韩欧美在线1卡| 欧美性色欧美a在线播放| 波多野结衣在线aⅴ中文字幕不卡| 欧美aaa在线| 亚洲大型综合色站| 亚洲精品午夜久久久| 国产精品久久久久桃色tv| 精品不卡在线视频| 91精品国产美女浴室洗澡无遮挡| 日本精品视频一区二区| 波多野结衣在线一区| 国产成人免费高清| 国产在线播放一区二区三区| 日韩影院精彩在线| 亚洲成人av资源| 亚洲精品欧美激情| 成人欧美一区二区三区| 国产精品美女久久久久久久久| 精品国产一区a| 欧美成人aa大片| 日韩免费视频一区二区| 日韩一区二区麻豆国产| 制服.丝袜.亚洲.另类.中文| 欧美亚日韩国产aⅴ精品中极品| 色综合天天综合在线视频| 成人avav影音| a级高清视频欧美日韩| 粉嫩嫩av羞羞动漫久久久 | 欧美sm美女调教| 日韩欧美一区二区视频| 欧美大片日本大片免费观看| 51久久夜色精品国产麻豆| 欧美电影影音先锋| 欧美一区二区在线不卡| 日韩色视频在线观看| 精品久久久久久久人人人人传媒| 精品少妇一区二区| 久久久久99精品一区| 国产欧美日本一区视频| 国产欧美日韩三区| 国产精品国产自产拍高清av| 国产精品无码永久免费888| 自拍偷拍国产精品| 亚洲最新视频在线观看| 日韩影视精彩在线| 激情欧美一区二区三区在线观看|