Skip to content

Commit

Permalink
进程调度
Browse files Browse the repository at this point in the history
  • Loading branch information
wanggx committed Mar 25, 2016
1 parent 483812c commit 638c439
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 1 deletion.
Binary file modified Kernel1.0.PFI
Binary file not shown.
Binary file modified Kernel1.0.PO
Binary file not shown.
Binary file modified Kernel1.0.PS
Binary file not shown.
Binary file modified Kernel1.0.WK3
Binary file not shown.
1 change: 1 addition & 0 deletions Linux1.0/include/linux/kernel_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#define DK_NDRIVE 4

/* ¼Ç¼ÄÚºË״̬ */
struct kernel_stat {
unsigned int cpu_user, cpu_nice, cpu_system;
unsigned int dk_drive[DK_NDRIVE];
Expand Down
2 changes: 1 addition & 1 deletion Linux1.0/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ __asm__("str %%ax\n\t" \
* This also clears the TS-flag if the task we switched to has used
* tha math co-processor latest.
*/
/* current在这个时候被改变
/* current在这个时候被改变,也就是切换到tsk这个进程
*/
#define switch_to(tsk) \
__asm__("cmpl %%ecx,_current\n\t" \
Expand Down
9 changes: 9 additions & 0 deletions Linux1.0/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ static unsigned long lost_ticks = 0;
* The "confuse_gcc" goto is used only to get better assembly code..
* Djikstra probably hates me.
*/

/* 进程调度函数
*/
asmlinkage void schedule(void)
{
int c;
Expand All @@ -225,6 +228,7 @@ asmlinkage void schedule(void)
need_resched = 0;
p = &init_task;
for (;;) {
/* 保证进程链表只扫描一圈 */
if ((p = p->next_task) == &init_task)
goto confuse_gcc1;
if (ticks && p->it_real_value) {
Expand All @@ -243,8 +247,13 @@ asmlinkage void schedule(void)
itimer_next = p->it_real_value;
}
end_itimer:
/* 如果进程是非可中断状态,则在选择调度的程序时,不考虑该进程,
* 如进程陷入一种不可中断的睡眠状态,则此时调度程序不可调度该进程
*/
if (p->state != TASK_INTERRUPTIBLE)
continue;
/* 如果进程接收到了信号,则设置进程的状态为运行态
*/
if (p->signal & ~p->blocked) {
p->state = TASK_RUNNING;
continue;
Expand Down

0 comments on commit 638c439

Please sign in to comment.