Linux Kernel Source - current 宏
来源:互联网 发布:知错改错的名人名言 编辑:程序博客网 时间:2024/04/30 21:42
今天在Linux 2.4源码sched.c中看到以下代码:
void sleep_on(wait_queue_head_t *q){SLEEP_ON_VARcurrent->state = TASK_UNINTERRUPTIBLE;SLEEP_ON_HEADschedule();SLEEP_ON_TAIL}sleep_on函数的主要作用是设置当前进程的状态为TASK_UNINTERRUPTIBLE,并将自己加入等待队列中。
我们知道记录进程状态的字段存在于进程描述符(task_struct)的state字段,那么current是如何得到当前进程的描述符地址的呢?如下:
static inline struct task_struct * get_current(void){struct task_struct *current;__asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));return current; } #define current get_current()以上是i386架构下curent.h中的定义,从中我们可以看到current = %esp & 0xffffe000,即进程描述符的地址等于进程内核栈的栈底地址与上 (~8191)。i386中内核栈与task_struct的关系如下图:
- Linux Kernel Source - current 宏
- linux kernel current宏
- linux kernel current宏
- linux kernel current宏
- linux kernel current宏
- Compile linux kernel source
- linux kernel source code
- Configure Linux kernel source
- get linux kernel source ubuntu
- Linux kernel source git repositories
- Linux kernel source build error
- Download Linux Kernel source code
- Linux Kernel---some source on the internet.
- Makefile65 Linux kernel source not found. stop
- Browse the Linux Kernel Source with LXR
- Browse the Linux Kernel Source with LXR
- Building a Linux Kernel from source
- Linux Kernel Source - 链表浅析
- Jackson 框架,轻易转换JSON
- 禁止另存网页 禁止右键 让页面文字不被选中和复制
- 工作七年的感想
- android 调用系统摄像头拍照及截剪
- PowerDesigner逆向工程
- Linux Kernel Source - current 宏
- 使用无线网络和切换到GPRS连接
- (译)如何优化cocos2d程序的内存使用和程序大小:第一部分
- Yahoo对网页设计性能的建议
- 【经典】上班犯困的自我解救方法
- android 自定义dialog弹出和消失动画
- 网上流传的内核开发面试题答案--欢迎指正
- xcode 4 svn配置(host is unreachable)
- 地图上经纬度的距离估计