1 / 16

Process Management

Process Management. Shi-Hui Ker OS Lab., NCTU,Taiwan. Data Structure. task[ NR_TASKS ]. …. state. counter. priority. init_task. Interrupts. Fast interrupts Slow interrupts Software interrupts(system calls). Bottom halves.

omar
Download Presentation

Process Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Data Structure task[NR_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_base[32])(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_cptr p_pptr 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->exit_signal); • notify_parent(p, p->exit_signal);

  15. wake_up_interruptible() p Wait_queue_head task task_struct 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. • flag=TASK_INTERRUPTIBLE • pass control to scheduler(call schedlu()) • when a process terminates, it signals this to its parent process via this queue.

More Related