Process%20Management - PowerPoint PPT Presentation

About This Presentation
Title:

Process%20Management

Description:

... Management. Shi-Hui Ker. OS Lab., NCTU,Taiwan. state. counter ... inform other processes if necessary. Call schedule() goto fake_volatile; Resources release ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 17
Provided by: ker128
Category:

less

Transcript and Presenter's Notes

Title: Process%20Management


1
Process Management
  • Shi-Hui Ker
  • OS Lab., NCTU,Taiwan

2
Data Structure
taskNR_TASKS
...
state
counter
priority
init_task
3
Interrupts
  • Fast interrupts
  • Slow interrupts
  • Software interrupts(system calls)

4
Bottom halves
  • a list of tasks to be performed that are
    necessary for the proper execution of things like
    device drivers, but do not need to be performed
    when an interrupt for that device is trapped.
  • void (bh_base32)(void)
  • bh_mask, bh_active
  • example kbd_bh

5
Schedule()
  • do_bottom_half()
  • run_task_queue(tq_scheduler)
  • Determine the fate of the previous process.
  • The process with the highest priority is
    determined.
  • Store the state of previous task, and restore the
    state of next task to CPU.

6
tq_struct
task_queue
next
next
next
sync
sync
sync
routine
routine
routine
data
data
data
7
Creating a Process
  • do_fork()
  • To allocate a new task_struct (p) from memory
    for the new process.
  • To allocate a new page for kernel stack.
  • To find an unused number from the task array.
  • To clone the task_struct with current process.
  • New process initialization.
  • Return process id to calling process(parent).

8
Process releationship
  • p_opptr original parent
  • p_cptr youngest child
  • p_ysptr younger sibling
  • p_osptr older sibling

9
Process releationship(cont.)
parent
p_pptr
p_cptr
p_pptr
p_pptr
p_osptr
p_osptr
oldest child
youngest child
child
p_ysptr
p_ysptr
10
Process termination
  • A process is always terminated by calling the
    kernel function do_exit.
  • Done by the system call _exit or by a
    unintercepted signal.

11
do_exit()
  • release the resources claimed by the current
    process
  • inform other processes if necessary.
  • Call schedule()
  • goto fake_volatile

12
Resources release
  • sem_exit()
  • if current process was sleeping for a semaphore,
    remove it from the wait queue.
  • __exit_mm(current)
  • flush cache, TLB
  • mmap, page table

13
Informing other processes
  • exit_notify()
  • forget_original_parent(current)
  • scan all processes and modifies the process
    pointers p_optr to init_task if they are
    pointing at current process.
  • kill_pg()
  • If the current process is leader of a group which
    includes the suspended processes, the messages
    SIGHUP and SIGCONT are sent to the group process
    by calling the function kill_pg().

14
Informing other processes(cont.)
  • notify_parent(current,current-gtexit_signal)
  • notify_parent(p, p-gtexit_signal)

15
wake_up_interruptible()
p
Wait_queue_head
task_struct
task
next
next
task
task_struct
next
task
task_struct
next
task
task_struct
next
Null
16
sys_wait4()
  • calling process must be halted until a child
    process terminates.
  • joins the wait_childexit wait queue in its own
    task structure.
  • flagTASK_INTERRUPTIBLE
  • pass control to scheduler(call schedlu())
  • when a process terminates, it signals this to its
    parent process via this queue.
Write a Comment
User Comments (0)
About PowerShow.com