资源简介
西电的操作系统课设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变换检测平行线的
相关资源
- 数据库课设:图书管理系统报告
- 计算机图形学课设 画板
- 教学计划编制系统
- 课程作业:模拟仓库管理系统
- KTV点播系统 软件工程课设
- 电子技术课设(自动日历表)multisi
- 基于SPCE061A单片机的图形液晶模块的驱
- 基于FPGA的电梯控制器系统设计
- 扎努西电气机械天津压缩机有限公司
- 在各城市的窄带物联网中传感器起到
- 用于无线传感器网络应用的超声波传
- 物联网无线传感器网络的7大特点
- 传感器在潜水设备的应用
- 旋转活塞式流量计的测量原理
- 设计电源管理电路时必需考虑的散热
- 电机型号Y、YS、YSF、YT、YC字母的含义
- BA8206BA4遥控风扇控制器的新应用
- 基于ARM7和DSP的逆变电源设计电路
- 基于LPC2134与T6963C液晶显示模块的接口
- 低功耗蓝牙无线传感器
- 基于FAN6754A的PWM反激式开关电源的设计
- 汽车线束类测试系统
- 电源设计小贴士 8:通过改变电源频率
- 光栅式万能测长仪的工作原理解析
- 基于LM35温度传感器的温控系统设计
- mems MEMS加速度传感器致力汽车主安全
- 采用单片机SPWM的控制应急电源逆变电
- 数据结构课设-模拟电梯
- FOR循环语句的翻译程序设计简单优先
- 计算机网络24分游戏课设完整版
评论
共有 条评论