
代码例子
zhangwenjianqin
这个作者很懒,什么都没留下…
展开
-
内核定时器的例子
#include #include #include #include #include struct timer_list stimer; //定义定时器static void time_handler(unsigned long data){ //定时器处理函数mod_timer(&stimer, jiffies + HZ);printk("cu转载 2012-05-23 17:17:48 · 514 阅读 · 0 评论 -
信号量实现内核线程同步例子
#include #include #include #include MODULE_LICENSE("GPL");int num[2][5] = {{0, 2, 4, 6, 8},{1, 3, 5, 7, 9}};struct semaphore sem_first;struct semaphore sem_second;int thr转载 2012-05-23 17:20:23 · 585 阅读 · 0 评论 -
bmp文件的读写
#include "stdio.h"#include "stdlib.h"#define PIXPLINE 320typedef struct tagRGBQUAD{ //定义每个像素的数据类型 unsigned char rgbBlue; unsigned char rgbGreen; unsigned ch转载 2012-06-14 10:29:07 · 1249 阅读 · 1 评论 -
makefile的写法
/* main.c */ #include "mytool1.h" #include "mytool2.h" int main(int argc,char **argv) { mytool1_print("hello"); mytool2_print("hello"); } /* mytool1.h */ #ifndef _MYTOOL_1_H #de原创 2009-10-27 21:54:00 · 8208 阅读 · 0 评论 -
获得本地时间的C语言代码
#include "time.h"#include "stdio.h"int main(){time_t seconds;struct tm * timeinfo;short hour,min,second,month,day;int year;time( &seconds );timeinfo = localtime ( &seconds );hour=转载 2009-10-27 21:48:00 · 859 阅读 · 0 评论 -
经典linux c telnet程序
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //转载 2011-05-12 21:59:00 · 4580 阅读 · 0 评论 -
多线程参数传递
Linux多线程编程的基本的函数 1线程创建 函数原型: #include int pthread_create(pthread_t *restrict tidp,const pthread_attr_t *restrict attr, void *(*start_rtn)(void),void *restrict arg);转载 2011-05-12 22:07:00 · 5895 阅读 · 0 评论 -
简单字符设备应用
#include #include #include #include #include #include #include #include #include #include #include #include MODULE_LICENSE("Dual BSD?GPL");int memory_open(struct inode *ino转载 2012-05-23 17:21:53 · 467 阅读 · 0 评论 -
从虚拟地址转为物理地址
/* mtest_dump_vma_list():打印出当前进程的各个VMA,这个功能我们简称”listvma” mtest_find_vma(): 找出某个虚地址所在的VMA,这个功能我们简称“findvma” my_follow_page( ):根据页表,求出某个虚地址所在的物理页面,这个功能我们简称”findpage” mtest_write_val(), 在某个地址写上具体转载 2012-05-23 17:24:28 · 934 阅读 · 0 评论 -
中断例子
usage: Compiling this file by make and using the following command to insert the mode which the make generated just nowcommand: sudo insmod filename.ko irq=1 devname=myirqThis interrupt shared t转载 2012-05-23 17:25:24 · 883 阅读 · 0 评论 -
完成量实现线程同步
#includelinux/init.h>#includelinux/module.h>#includelinux/sched.h>#includelinux/sem.h>MODULE_LICENSE("Dual BSD/GPL");struct completion my_completion1;struct completion my_completion2;//定转载 2012-05-28 14:03:53 · 557 阅读 · 0 评论 -
定时器简单应用(挂起进程)
#include #include #include #include #include struct timer_list stimer; //定义定时器int timeout = 10 * HZ;static void time_handler(unsigned long data){ //定时器处理函数,执行该函数获取挂起进程的pid,唤醒该进程struct转载 2012-05-23 17:19:31 · 1212 阅读 · 0 评论