欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年操作系统期中试卷 3.pdf

    • 资源ID:39670915       资源大小:35.72KB        全文页数:4页
    • 资源格式: PDF        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年操作系统期中试卷 3.pdf

    4.1 Provide two programming examples in which multithreading does not provide better performance than a single-threaded solution Answer:(1)Any kind of sequential program is not a good candidate to be threaded.An example of this is a program that calculates an individualtax return.(2)Another example is a shell program such asthe C-shell or Korn shell.Such a program must closely monitor its own working space such as open files,environment variables,and current working directory.4.2 Describe the actions taken by a thread library to context switch between user-level threads.Answer:Context switching between user threads is quite similar to switching between kernel threads,although it is dependent on the threads library and how it maps user threads to kernel threads.In general,context switching between user threads involves taking a user thread of its LWP and replacing it with another thread.This act typically involves saving and restoring the state of the registers.4.3 Under what circumstances does a multithreaded solution using multiple kernel threads provide better performance than a single-threaded solution on a single-processor system?Answer:When a kernel thread suffers a page fault,another kernel thread can be switched in to use the interleaving time in a useful manner.A single-threaded process,on the other hand,will not be capable of performing useful work when a page fault takes place.Therefore,in scenarios where a program might suffer from frequent page faults or has to wait for other system events,a multi-threaded solution would perform better even on a single-processor system.4.4 Which of the following components of program state are shared across threads in a multithreaded process?a.Register values b.Heap memory c.Global variables d.Stack memory Answer:The threads of a multithreaded process share heap memory and global variables.Each thread has its separate set of register values and a separate stack.名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 4 页 -4.5 Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on a single-processor system?Answer:A multithreaded system comprising of multiple user-level threads cannot make use of the different processors in a multiprocessor system simultaneously.The operating system sees only a single process and will not schedule the different threads of the process on separate processors.Consequently,there is no performance benefit associated with executing multiple user-level threads on a multiprocessor system.4.6 As described in Section 4.5.2,Linux does not distinguish between processes and threads.Instead,Linux treats both in the same way,allowing a task to be more akin to a process or a thread depending on the set of flags passed to the clone()system call.However,many operating systems such as Windows XP and Solaris treat processes and threads differently.Typically,such systems use a notation wherein the data structure for a process contains pointers to the separate threads belonging to the process.Contrast these two approaches for modeling processes and threads within the kernel.Answer:On one hand,in systems where processes and threads are considered as similar entities,some of the operating system code could be simplified.A scheduler,for instance,can consider the different processes and threads in equal footing without requiring special code to examine the threads associated with a process during every scheduling step.On the other hand,this uniformity could make it harder to impose process-wide resource constraints in a direct manner.Instead,some extra complexity is required to identify which threads correspond to which process and perform the relevant accounting tasks.4.7 The program shown in Figure 4.11 uses the Pthreads API.What would be output from the program at LINE C and LINE P?Answer:Output at LINE C is 5.Output at LINE P is 0.4.8 Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model.Let the number of user-level threads in the program be more than the number of processors 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 processors.b.The number of kernel threads allocated to the program is equal to the number of 名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 4 页 -processors.c.The number of kernel threads allocated to the program is greater than the number of processors but less than the number of user level threads.Answer:When the number of kernel threads is less than the number of processors,then some of the processors would remain idle since the scheduler maps only kernel threads to processors and not user-level threads to processors.When the number of kernel threads is exactly equal to the number of processors,then it is possible that all of the processors might be utilized simultaneously.However,when a kernel thread blocks inside the kernel(due to a page fault or while invoking system calls),the corresponding processor would remain idle.When there are more kernel threads than processors,a blocked kernel thread could be swapped out in favor of another kernel thread that is ready to execute,thereby increasing the utilization of the multiprocessor system.4.9 Write a multithreaded Java,Pthreads,or Win32 program that outputs prime numbers.This program should work as follows:The user will run the program and will enter a number on the command line.The program will then create a separate thread that outputs all the prime numbers less than or equal to the number entered by the user.Answer:Please refer to the supporting Web site for source code solution.4.10 Modify the socket-based date server(Figure 3.19)in Chapter 3 so that the server services each client request in a separate thread.Answer:Please refer to the supporting Web site for source code solution.4.11 The Fibonacci sequence is the series of numbers 0,1,1,2,3,5,8,.Formally,it can be expressed as:f ib0=0 f ib1=1 f ibn=f ibn-1+f ibn-2 Write a multithreaded program that generates the Fibonacci series using either the Java,Pthreads,or Win32 thread library.This program should work as follows:The user will enter on the command line the number of Fibonacci numbers that the program is to generate.The program will then create a separate thread that will generate the Fibonacci numbers,placing the sequence in data that is shared by the threads(an array is probably 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 4 页 -the most convenient data structure).When the thread finishes execution,the parent thread will output the sequence generated by the child thread.Because the parent thread cannot begin outputting the Fibonacci sequence until the child thread finishes,this will require having the parent thread wait for the child thread to finish using the techniques described in Section 4.3.Answer:(Please refer to the supporting Web site for source code solution.)4.12 Exercise 3.9 in Chapter 3 specifies designing an echo server using the Java threading API.However,this server is single-threaded meaning the server cannot respond to concurrent echo clients until the current client exits.Modify the solution to Exercise 3.9 such that the echo server services each client in a spearate request Answer:Please refer to the supporting Web site for source code solution.名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 4 页 -

    注意事项

    本文(2022年操作系统期中试卷 3.pdf)为本站会员(H****o)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开