注册 登录
编程论坛 Linux系统管理

计算机2

madfrogme 发布于 2012-10-09 22:37, 5961 次点击
内核如何跟踪它是否能够被抢占?

回想一下,可知系统中的每个进程都有一个特定于体系结构的 struct thread_info 实例。

该结构也包含了一个抢占计数器(preemption counter )

<asm-arch/thread_info.h>

struct thread_info {
...
        int preempt_count;        /* 0  =>  可抢占, <0 =>  Bug */
...
}

preempt_count 为零,则内核可以被中断, 否则不行。

该值只能通过 dec_preempt_count , inc_preempt_count 两个函数对计数器减1 或 加 1。

每次内核进入重要区域,需要禁止抢占时,都会调用inc_preempt_count。

退出该区域时,调用dec_preempt_count 将抢占计数器减1


[ 本帖最后由 madfrogme 于 2012-10-11 18:27 编辑 ]
10 回复
#2
madfrogme2012-10-09 22:50
进程的入队和离队都比较简单,

只需以 p->prio 为索引访问 queue 数组 queue[p->prio] ,

即可获得正确的链表,将进程加入链表或从链表删除即可, 新进程总是排列在每个链表的末尾

kernel/sched.c

struct rt_prio_array {
    DECLARE_BITMAP(bitmap, MAX_RT_PRIO+1); /* include 1 bit for delimiter */
    struct list_head queue[MAX_RT_PRIO];
};


[ 本帖最后由 madfrogme 于 2012-10-11 18:27 编辑 ]
#3
madfrogme2012-10-09 23:01
实时进程与普通进程有一个根本的不同之处: 如果系统中有一个实时进程且可以运行,

那么调度器总是会选中它运行, 除非有另一个优先级更高的进程
#4
madfrogme2012-10-09 23:08
内核线程没有自身的用户空间内存上下文, 可能在某个随机进程地址空间的上部执行,

其 task_struct->mm 为 NULL, 从当前进程“借来”的地址空间记录在 active_mm
#5
madfrogme2012-10-10 16:12
1. One thing that segmentation can do that paging can't, and that's set the ring level.

2. GRUB sets a GDT up for you.


[ 本帖最后由 madfrogme 于 2012-10-10 17:15 编辑 ]
#6
madfrogme2012-10-10 16:43
只有本站会员才能查看附件,请 登录
#7
madfrogme2012-10-11 17:26
Note for the %'d one to work you must have already set your locale as in the following example:

#include <locale.h>
#include <stdio.h>

int main(void)
{
    setlocale(LC_ALL,"");
    printf("%'d\n",1234);
}

$ ./a.out
1,234
#8
madfrogme2012-10-17 14:25
Any separate partition that you want

automatically mounted upon boot

 needs to be specified in the /etc/fstab
#9
madfrogme2012-10-19 14:27

ARP spoofing attack

Generally, the goal of the attack is to

associate the attacker's MAC address with the IP address of a target host,

so that any traffic meant for the target host will be sent to the attacker's MAC instead.
#10
madfrogme2012-10-23 23:45
The popen function accepts as its first argument a string containing a shell command, such as lpr.

Its second argument is a string containing either the mode argument r or w.

If you specify r, the pipe will be open for reading; if you specify w, it will be open for writing.
#11
madfrogme2012-11-20 16:28
对socket 的I/O 操作进行超时设置,有3种方法

1.调用alarm() ( alarm()的返回值是timer中的剩余时间)

2.在select()处阻塞等待

3.在socket选项中设定SO_RCVTIMEO 或 SO_SNDTIMEO

但这个方法不是所有实现都支持


[ 本帖最后由 madfrogme 于 2012-11-20 17:33 编辑 ]
1