西电操作系统课程设计报告1alarm_clockPintos
西电的操作系统课设报告第一份,不含源码(没必要)。其实这一份老师给的资料很详细了,所以本报告不用分数,仅用作进一步理解的参考,以及格式参考吧。若需第二第三份,我也上传了,其中包含课设2、3次(priority_scheduling)的报告和代码,欢迎下载不过得要个几分噢~~……
课设最终成绩90+,不用担心质量。
班蔡文韬
西安电子科技大学操作系统课程设计报告
timer sleep (int64 t ticks)
if(ticks >0
enum intr level old level
old level= intr disabled
thread blocko: block th
read
intr set level(old level)
如上图,采用
将线程阻塞,而不是在函数内部使用不停循
环检查是否到阻塞时间,可以有效防止线程在等待期间仍然占用的情况发生。
步骤二
之后,在
中,为
结构体加上计数线程阻塞时间的变量
struct thread
k Owned by thread. c
tid t tid
/s Thread identifier si,
enum thread status status
Thread state s
char namely
I Name(for debugging purposes)
uint8 t*stack
Saved stack pointer
int D11orit
Priority
struct list elem allele
List element for all threads list *p,
r Shared bctwccn thread. c and synch. c a
struct list elem ele
/a List element. */
int block ticks
线程阻塞时间+
如图,该变量川于标记该线程仍需阻塞多长时间,当该变量为时,意味着
等待结束,该线程将会被调入
中
步骤三
定义
函数中需要调用的函数
西安电子科技大学操作系统课程设计
班蔡文韬
void block check(strict thread *t, voidsalx UNUSED)
if(t->status- THREAD BlOCKED && t-block ticks > 0)
t->block ticks--
if(t->block ticks ==0
thread unblock(t)
如图,该函数用于检查传入线程是否处于阻塞状态,若是,将其成员
(详见步骤二)自减一后再判断是否为,若是,唤醒该线程进入
步骤四
修改
,对每个线程调用
函数。
timer interrupt (struct intr frameargs UNUSED
ticks++.
enum intr level old level;/记录原来的中断状态
old level:= intr disable0; thread foreach函数要求关中断。
thread foreach (block check, NULL;
intr set level( old level);/恢复中断
thread tick (-
如图,在每次定时器中断时遍历所有线程,从而实现对所有阻塞线程
成员减一并判断是否达到唤醒要求的功能。
4、成果
班蔡文韬
西安电子科技大学操作系统课程设计报告
pass tests/threads/alarm-single
pass tests/threads/alarm-multiple
pass tests/threads/alarm-simultaneous
FAIL tests/threads/alarm-priority
pass tests/threads/alarm-zero
pass tests/threads/alarm-negative
FAIL tests/threads/priority-change
FAIL tests/threads/priority-donate-one
FAIL tests/threads/priority-donate-multiple
FAIL tests/threads/priority-donate-multiple2
FAIL tests/threads/priority-donate-nest
FAIL tests/threads/priority-donate-sema
FAIL tests/threads/priority-donate-lower
FAIL tests/threads/priority-fifo
FAIL tests/threads/priority-preempt
FAIL tests/threads/priority-sema
FAIL tests/threads/priority-condvar
FAIL tests/threads /priority-donate-chain
FAIL tests/threads/mlfqs-load-1
FAIL tests/threads /mlfgs-load-60
FAIL tests/threads/mlfqs-load-avg
FAIL tests/threads/mlfqs-recent-1
pass tests/threads/mlfgs-fair-2
pass tests/threads/mlfqs-fair-20
FAIL tests/threads/mlfgs-nice-2
FAIL tests/threads/mlfqs-nice-10
FAIL tests/threads/mlfqs-block
20。f27 tests fai1ed
在侈改完成后,调用
命令对
了目录进行任务检查,结果
满足题目要求。
5、结论
所谓忙等待,即当线程处于等待状态时仍然占用CPU的情况。要防止这种情
况的发生,我们不能采用 while循环检查是否等待到预期时问的方式。在本报告
中,我采用了给线程添加一个计数变量,每次时问中断时为所有处于阻塞队列中
的线程的这个变量减一,并判断是否减到0,若是唤醒,否则不做任何操作。这样
的方式初步实现了线程在等待阶段能将CPU让出的功能,防止了“忙等待”的发
生
课设最终成绩90+,不用担心质量。
班蔡文韬
西安电子科技大学操作系统课程设计报告
timer sleep (int64 t ticks)
if(ticks >0
enum intr level old level
old level= intr disabled
thread blocko: block th
read
intr set level(old level)
如上图,采用
将线程阻塞,而不是在函数内部使用不停循
环检查是否到阻塞时间,可以有效防止线程在等待期间仍然占用的情况发生。
步骤二
之后,在
中,为
结构体加上计数线程阻塞时间的变量
struct thread
k Owned by thread. c
tid t tid
/s Thread identifier si,
enum thread status status
Thread state s
char namely
I Name(for debugging purposes)
uint8 t*stack
Saved stack pointer
int D11orit
Priority
struct list elem allele
List element for all threads list *p,
r Shared bctwccn thread. c and synch. c a
struct list elem ele
/a List element. */
int block ticks
线程阻塞时间+
如图,该变量川于标记该线程仍需阻塞多长时间,当该变量为时,意味着
等待结束,该线程将会被调入
中
步骤三
定义
函数中需要调用的函数
西安电子科技大学操作系统课程设计
班蔡文韬
void block check(strict thread *t, voidsalx UNUSED)
if(t->status- THREAD BlOCKED && t-block ticks > 0)
t->block ticks--
if(t->block ticks ==0
thread unblock(t)
如图,该函数用于检查传入线程是否处于阻塞状态,若是,将其成员
(详见步骤二)自减一后再判断是否为,若是,唤醒该线程进入
步骤四
修改
,对每个线程调用
函数。
timer interrupt (struct intr frameargs UNUSED
ticks++.
enum intr level old level;/记录原来的中断状态
old level:= intr disable0; thread foreach函数要求关中断。
thread foreach (block check, NULL;
intr set level( old level);/恢复中断
thread tick (-
如图,在每次定时器中断时遍历所有线程,从而实现对所有阻塞线程
成员减一并判断是否达到唤醒要求的功能。
4、成果
班蔡文韬
西安电子科技大学操作系统课程设计报告
pass tests/threads/alarm-single
pass tests/threads/alarm-multiple
pass tests/threads/alarm-simultaneous
FAIL tests/threads/alarm-priority
pass tests/threads/alarm-zero
pass tests/threads/alarm-negative
FAIL tests/threads/priority-change
FAIL tests/threads/priority-donate-one
FAIL tests/threads/priority-donate-multiple
FAIL tests/threads/priority-donate-multiple2
FAIL tests/threads/priority-donate-nest
FAIL tests/threads/priority-donate-sema
FAIL tests/threads/priority-donate-lower
FAIL tests/threads/priority-fifo
FAIL tests/threads/priority-preempt
FAIL tests/threads/priority-sema
FAIL tests/threads/priority-condvar
FAIL tests/threads /priority-donate-chain
FAIL tests/threads/mlfqs-load-1
FAIL tests/threads /mlfgs-load-60
FAIL tests/threads/mlfqs-load-avg
FAIL tests/threads/mlfqs-recent-1
pass tests/threads/mlfgs-fair-2
pass tests/threads/mlfqs-fair-20
FAIL tests/threads/mlfgs-nice-2
FAIL tests/threads/mlfqs-nice-10
FAIL tests/threads/mlfqs-block
20。f27 tests fai1ed
在侈改完成后,调用
命令对
了目录进行任务检查,结果
满足题目要求。
5、结论
所谓忙等待,即当线程处于等待状态时仍然占用CPU的情况。要防止这种情
况的发生,我们不能采用 while循环检查是否等待到预期时问的方式。在本报告
中,我采用了给线程添加一个计数变量,每次时问中断时为所有处于阻塞队列中
的线程的这个变量减一,并判断是否减到0,若是唤醒,否则不做任何操作。这样
的方式初步实现了线程在等待阶段能将CPU让出的功能,防止了“忙等待”的发
生
- 基于QT实现串口数据收发及多路数据动态显示_qt实现同时接收多个串口数据,qt串口如何同时收发数据
- HFSS传输线串扰分析与仿真实验
- Windows环境VS2017编译skia库-m84之已编译的库文件等_skiawindows编译,skiawindows编译
- pintos操作系统实验27个全pass_pintos,pintos实验
- VC++comcom
- in-vc++example
- N76E003仿真驱动Nuvoton_8051_Keil_uVision_Driver_v2.00.6561.zip
- stm32超声波避障小车及程序设计报告.rar
- MFC串口-VS2017-收发.zip
- 汉翔大将军手写板驱动v8.0中文版
- C++builder下使用API函数利用多线程实现串口通信源程序
- uart串口调试115200工程文件
- STM32串口IAP的bootloader
- 自适应滑模控制matlab仿真_自适应滑模控制,自适应滑模
- 基于51单片机sht11仿真图
- DHT22温湿度传感器仿真proteus+keil.zip
- 基于STM32F103R6模拟的数字电压表实现_基于stm32的数字电压表设计
- usb2.0-serial驱动下载_usb2.0-serial驱动
- PCF8576IIC初始化程序
- 一个修改本机IP、掩码、网关、DNS、带PING功能小程序
- linux下基于udp协议的聊天室(私聊、群聊、广播)