资源简介
西电的操作系统课设3(优先级捐赠方法解决优先级翻转问题),含源码(只放了四个需要修改的c和h文件,都是在课设2的基础上做的,课设2和3的代码均备注了修改的起末段落,且使用了不尽相同的备注)。该做法参考了【LY】的帮助手册,我在实验方案中给了相当详细的说明。代码结合说明来做的话,理解这题应该没什么问题。
课设最终成绩90+,不用担心质量。
最后一个提醒,每个学校OS课设不一样,我这个是用优先级捐赠的方法解决优先级翻转问题(当然是针对Pintos内核)。
(总觉得自己想赚点CSDN积分也是蛮拼的= =||。So学弟学妹们酷爱来下吧括弧笑~)
代码片段和文件信息
/* This file is derived from source code for the Nachos
instructional operating system. The Nachos copyright notice
is reproduced in full below. */
/* Copyright (c) 1992-1996 The Regents of the University of California.
All rights reserved.
Permission to use copy modify and distribute this software
and its documentation for any purpose without fee and
without written agreement is hereby granted provided that the
above copyright notice and the following two paragraphs appear
in all copies of this software.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO
ANY PARTY FOR DIRECT INDIRECT SPECIAL INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE
AND ITS DOCUMENTATION EVEN IF THE UNIVERSITY OF CALIFORNIA
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN “AS IS“
BASIS AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
PROVIDE MAINTENANCE SUPPORT UPDATES ENHANCEMENTS OR
MODIFICATIONS.
*/
#include “threads/synch.h“
#include
#include
#include “threads/interrupt.h“
#include “threads/thread.h“
/* Initializes semaphore SEMA to VALUE. A semaphore is a
nonnegative integer along with two atomic operators for
manipulating it:
- down or “P“: wait for the value to become positive then
decrement it.
- up or “V“: increment the value (and wake up one waiting
thread if any). */
void
sema_init (struct semaphore *sema unsigned value)
{
ASSERT (sema != NULL);
sema->value = value;
list_init (&sema->waiters);
}
/* Down or “P“ operation on a semaphore. Waits for SEMA‘s value
to become positive and then atomically decrements it.
This function may sleep so it must not be called within an
interrupt handler. This function may be called with
interrupts disabled but if it sleeps then the next scheduled
thread will probably turn interrupts back on. */
void
sema_down (struct semaphore *sema)
{
enum intr_level old_level;
ASSERT (sema != NULL);
ASSERT (!intr_context ());
old_level = intr_disable ();
while (sema->value == 0)
{
/*CC3-----added------*/
thread_current()->block_sema = sema;//记录sema
/*CC-----finish------*/
/*CC2-----deleted-----*/
// list_push_back (&sema->waiters &thread_current ()->elem);
/*CC2-----addeded-----*/
list_insert_ordered(&sema->waiters&thread_current ()->elemthread_lessNULL);
/*CC-----finish-----*/
thread_block ();
}
sema->value--;
intr_set_level (old_level);
}
/* Down or “P“ operation on a semaphore but only if the
semaphore is not already 0. Returns true if the semaphore is
decremented false otherwise.
This function may be called from an interrupt handler. */
bool
sema_try_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 390106 2014-12-18 22:14 OS课设3.pdf
文件 685228 2011-12-17 19:08 Screenshot from 2011-12-17 19_08_33.png
目录 0 2015-01-18 15:05 代码\
文件 12031 2014-12-18 21:29 代码\synch.c
文件 1627 2014-12-17 23:03 代码\synch.h
文件 18997 2014-12-18 21:29 代码\thread.c
文件 5976 2014-12-18 20:06 代码\thread.h
- 上一篇:RTKPPP定位算法流程.pdf
- 下一篇:hough变换检测平行线的
相关资源
- 西安电子科技大学计算机学院微机原
- 交通灯单片机课设
- Hadoop编程课程设计项目.zip
- 西电毕设手册
- 超外差收音机仿真和实物测试报告 西
- 计算机组成原理课设140852
- 操作系统课设两道批处理系统的两极
- 数据结构课设文件系统模拟器
- 简易聊天工具计算机网络课设
- 信息管理系统 答辩ppt 课设,毕设
- 课设:中型载货汽车驱动桥设计 cat
- 西电编译原理大作业
- 嵌入式图形界面计时器课设报告
- zw_qq_30612787-10390434-数字信号处理—课
- 数据库课设——学生选课系统
- UML课设移动端公交车查询系统需求分
- 西电数据挖掘大作业之电影评级数据
- 机械设计二级减速器课设
- 山东大学操作系统课设实验报告.zip
- 网页制作课设论文及作品
- 整套软件工程课设文档和程序
- 吉林大学数据结构课设
- 西电信号与系统笔记信号与线性系统
- 编译原理课程设计 SLR(1)文法
- fpga实现qpsk 南航通信综合课设
- 最优化计算方法 陈开周版 西电 完整
- 广工数据结构课设
- 软件设计体系结构课设
- 西电组合数学课后习题答案
- 西电数字信号处理课件
评论
共有 条评论