RE: scheduler question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
> 
> Hi.
> 
> I've been reading through a little bit on how the scheduler 
> works, and I was wondering how exactly when it goes back to a 
> process that was pre-empted/put to sleep/interrupted in 
> general, does it know where to continue execution? i.e. if 
> the program completed X instructions before it was 
> interrupted- how does it know to start at X+1 ?
> 

The important thing happens during a process switch is the change of
kernel mode stack of the process ( From previous process to the next
process's stack ) and the rest of the thing follows. In simple terms, a
IRET instruction will cause the execution of the instruction X+1 ( when
that process was last interuppted ) because CPU is now working with the
next process stack.

Also, one important macro is "current" ( points to the tast_struct of
the running process ) which is actually derived from the stack pointer
of the processor.


> jnf
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux