Pintos 西电操作系统课程设计3 报告+代码 Priority Donate
西电的操作系统课设3(优先级捐赠方法解决优先级翻转问题),含源码(只放了四个需要修改的c和h文件,都是在课设2的基础上做的,课设2和3的代码均备注了修改的起末段落,且使用了不尽相同的备注)。该做法参考了【LY】的帮助手册,我在实验方案中给了相当详细的说明。代码结合说明来做的话,理解这题应该没什么问题。
课设最终成绩90+,不用担心质量。
最后一个提醒,每个学校OS课设不一样,我这个是用优先级捐赠的方法解决优先级翻转问题(当然是针对Pintos内核)。
(总觉得自己想赚点CSDN积分也是蛮拼的= =||。So学弟学妹们酷爱来下吧括弧笑~)
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 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 代码 hread.c
文件 5976 2014-12-18 20:06 代码 hread.h
/* 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 代码 hread.c
文件 5976 2014-12-18 20:06 代码 hread.h
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)