内核
文章平均质量分 73
A疯的码农
CPIC
展开
-
用calloc分配10块大小为4字节的内存空间,打印指针地址,并且打印出内存中的内容
#include#include#include int main(void) { int i; int *str = NULL; str = (int*)calloc(10, sizeof(int)); if(str==NULL) { printf("calloc error!\n");原创 2014-09-18 13:23:23 · 1042 阅读 · 0 评论 -
第一章-任务1:Linux内核的重新编译,安装,重启
1.1 相关知识 Linux内核是一个用C语言写成的,符合POSIX标准的类Unix操作系统。内核是操作系统中最基本的一部分,提供了众多应用程序访问计算机硬件的机制。Linux内核的一大特点就是采用了整体式结构,有很多过程组成,每个过程都可以独立编译,其模块机制又湿得内核保持独立而又易于扩充。Linux发行版是在Linux内核的基础之上,与外带的应用软件和工具打包配置之后发行的版本。最初的Li原创 2014-09-02 13:18:37 · 902 阅读 · 0 评论 -
安装内核模块的编译环境
安装内核模块的编译环境一、 下载新内核的源代码 目前,在Internet上提供Linux源代码的站点有很多,读者可以选择一个速度较快的站点下载。本人是从站点www.kernel.org上下载了Linux的开发版内核3.14.17的源代码,全部代码被压缩到一个名叫Linux-3.14.17.tar.gz的文件中。二、 释放内核源代码 由于源代码放在一个压缩文件中,因此在配置内核之前,原创 2014-09-03 08:46:54 · 901 阅读 · 0 评论 -
Linux内核编译过程的优化
原始内核编译安装内核模块的编译环境一、 下载新内核的源代码 (负责人:王东升)目前,在Internet上提供Linux源代码的站点有很多,读者可以选择一个速度较快的站点下载。本人是从站点www.kernel.org上下载了Linux的开发版内核3.14.17的源代码,全部代码被压缩到一个名叫Linux-3.14.17.tar.gz的文件中。二、 释放内核源代码 (负责人:赵培)原创 2014-09-03 14:38:41 · 1314 阅读 · 0 评论 -
linux内核模块依赖图
Module Size Used bybtrfs 880032 0 raid6_pq 97812 1 btrfsxor 21411 1 btrfsufs 74837 0 qnx4原创 2014-09-04 10:44:41 · 2321 阅读 · 0 评论 -
内存分配
#include #include #include #include #include using namespace std;#define MAX_ORDER 11map> process_info;struct page{ struct page *lru;};struct list_head{ struct pa原创 2014-09-17 11:53:49 · 946 阅读 · 0 评论 -
linux读写锁
#include#include#include#include#includestatic int i=0,j=100;//一个线程从0开始加,一个线程从100开始加struct task_struct *MyThread1=NULL;//线程1struct task_struct *MyThread2=NULL;//线程2static int myVar = 0原创 2014-09-30 10:44:53 · 1592 阅读 · 0 评论 -
linux顺序锁
#include#include#include#include#include#include//顺序锁头文件static int i=0,j=100;//一个线程从0开始加,一个线程从100开始加struct task_struct *MyThread1=NULL;//线程1struct task_struct *MyThread2=NULL;//线程2st原创 2014-09-30 10:43:37 · 1355 阅读 · 0 评论 -
linux自旋锁
#include#include#include#include#includestatic int i=0,j=100;struct task_struct *MyThread1=NULL;struct task_struct *MyThread2=NULL;static int myVar = 0;static int count = 0;spinloc原创 2014-09-30 10:46:20 · 991 阅读 · 0 评论 -
理解start_kernel中函数语句的作用
asmlinkage void __init start_kernel(void){ char * command_line; extern const struct kernel_param __start___param[], __stop___param[]; /*这两个变量为地址指针,指向内核启动参数处理相关结构体段在内存中的位置(虚拟地址)。原创 2014-09-12 14:47:38 · 1384 阅读 · 0 评论 -
检查打开的文件是不是ELF格式的文件,如果是就输出节头表表項的数目,各表項指向的节的地址
#include "elf.h"#include int main(int argc, char *argv[]){ FILE *fp; int i = 0; int fd = 0; Elf64_Ehdr ehdr; if ((fp=fopen(argv[1],"r"))==NULL) {原创 2014-09-12 08:42:18 · 869 阅读 · 0 评论 -
使用malloc分别分配2KB,6KB的内存空间,打印指针地址
#include#include#include #includeint main(void) { int *str1 = NULL; int *str2 = NULL; str1 = (int*)malloc(2*1024*sizeof(char)); str2 = (int*)malloc(6*1024*sizeof(char))原创 2014-09-18 13:26:15 · 1783 阅读 · 0 评论 -
使用malloc分别分配2KB的空间,然后用realloc调整为6KB的内存空间,打印指针地址
#include#include#include #includeint main(void) { int *str1 = NULL; int *str2 = NULL; str1 = (int*)malloc(2*1024*sizeof(char)); if(str1==NULL) { printf("m原创 2014-09-18 13:25:20 · 780 阅读 · 0 评论 -
使用malloc分别分配2KB的空间,然后用realloc调整为6KB、1MB、3MB、10MB空间,并且将这五块内存分别用“A”、“B”、“C”、“D”、“E”填充
#include#include#include #includeint main(void) { char *str1 = NULL; char *str2 = NULL; char *str3 = NULL; char *str4 = NULL; char *str5 = NULL; str1 = (char*)原创 2014-09-18 13:28:38 · 1713 阅读 · 0 评论 -
Multiboot规范
一个启动载入器/OS映像接口主要是三个方面:1 由启动载入器看到的一个OS映像的格式。2 当启动载入器启动一个操作系统时,机器的状态。3 由启动载入器传递给操作系统的信息的格式。3.1. OS映像的格式一个OS映像可能是一个,对于这个特定的操作系统而言,标准格式的普通32位可执行文件,除了它可能被链到一个非缺省的载原创 2014-09-10 10:44:32 · 3277 阅读 · 0 评论 -
内核启动过程
具体要求如下:Grub的源码分析:Grub如何支持多个系统和内核的启动选择(MultiBoot机制)。一.GRUB 简介(介绍主流的系统管理程序grub)什么是GRUB;GNU GRUB 是一个多重操作系统启动管理器。GNU GRUB 是由GRUB(GRand Unified Bootloader) 派生而来。GRUB 最初由Erich Stefan Boleyn 设计和应原创 2014-09-10 10:42:35 · 1452 阅读 · 0 评论 -
检查打开的文件是不是ELF格式的文件,如果是就输出节头表的文件偏移
#include #include #include #include #include #include #include #include "elf.h" #define FALSE 0#define TURE 1#define MAX_SIZE 52#define Elf_Ehdr Elf64_Ehdrint OpenElf(char *fi原创 2014-09-12 08:38:01 · 959 阅读 · 0 评论 -
检查打开的文件是不是ELF格式的文件,如果是就输出节头字符串表的地址,并依次输出各节的名称,字符串
#include "elf.h"#include int main(int argc, char *argv[]){ FILE *fp; int i = 0; int fd = 0; Elf64_Ehdr ehdr; if ((fp=fopen(argv[1],"r"))==NULL) {原创 2014-09-12 08:46:31 · 997 阅读 · 0 评论 -
检查打开的文件是不是ELF格式的文件,提取“特别”的节中的信息
//检查打开的文件是不是ELF格式的文件//检验ELF头//获得节头表的地址//遍历节头表,依次查看一个节的属性,从节头字符串表中找到其名称,如果名称和“特别”的section名匹配,则找到此节的地址//提取“特别”的节中的信息 //显示上面提取的信息#include#include#include#includeint main(int argc,char原创 2014-09-12 08:47:45 · 1454 阅读 · 1 评论 -
用c语言完成一个双向链表的创建,插入,删除
/*dlist.h*/ #ifndef DList_H #define DList_H typedef int Item; typedef struct Node * PNode; //节点指针 typedef PNode Position; //节点位置 /*定义节点类型*/ typedef struct原创 2014-09-13 08:38:03 · 3685 阅读 · 1 评论