os
纵浪大化中,喜,惧
这个作者很懒,什么都没留下…
展开
-
终端设备字符显示的控制
原创 2022-02-20 09:03:12 · 225 阅读 · 0 评论 -
地址映射与共享
#include <linux/mm.h>/*for get_free_page,put_page*/ #include<linux/sched.h>/*for pointer current,get_base*/ #include<linux/kernel.h>/*上次没有这个出毛病*/ unsigned long RAM[20];/*储存物理地址*/ int sys_shmget(int key) { if(!RAM[key])/*如果没有分配物理地址*/ {原创 2022-01-25 16:26:40 · 405 阅读 · 0 评论 -
信号量的实现和应用
此实验最难的地方:读了文件的数字以后怎么记录哪些读过 参考 我在内核态加了一个consumption变量和两个用于读/写consumption的系统调用. 遇到的坑:sem.h make以后复制才行 不能在用户态下访问内核态的内存.,所以我一开始不知道怎么停止消费者进程, 比较有趣的地方:把把int型变量的地址强行转化为char*类型,对其每一个字节进行操作.进程休眠和唤醒队列我用的是显式队列 主程序 #define __LIBRARY__ #include <stdio.h>/*sprintf原创 2022-01-20 21:01:45 · 318 阅读 · 0 评论 -
基于内核栈切换的进程切换
记载我的一些收获: 1switch_to是汇编,c语言调用时,可以在其源文件上加. globl switch_to 2first_return_from_kernel是汇编,使用extern void first_return_from_kernel(void)后,将first_return_from_kernel放入栈中,ret后即可执行 3网上代码有一个错误,但是我运行了没出错,在这里指出: 应该等于(33*16)+4,因为(让我对c语言struct这一数据结构更加清晰) 这个一个是16字节 4当我改原创 2022-01-17 14:25:22 · 470 阅读 · 0 评论 -
进程运行轨迹的跟踪与统计
在这里我记录一下process.c文件,别忘了如果在printk里面写了fprintk,需要再在kernel.h头文件里加上fprintk的函数原型 #include <stdio.h> #include <unistd.h> #include <time.h> #include <sys/times.h> #include <sys/wait.h> #define HZ 100 void cpuio_bound(int last, int cp原创 2022-01-14 13:32:14 · 226 阅读 · 0 评论