1 / 22

Process

Process. init_task idle init pid : 1 task process, thread copy on write. Task Structure. include/kernel/sched.h struct task_strcut { …} ; struct task_struct * next_task, * prev_task ; struct task_struct * next_run, * prev_run ; struct task_struct * p_opptr, * p_pptr,

maja
Download Presentation

Process

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

  2. init_task idle • init pid : 1 • task process, thread • copy on write

  3. Task Structure • include/kernel/sched.h • struct task_strcut { …} ; • struct task_struct * next_task, * prev_task ; • struct task_struct * next_run, * prev_run ; • struct task_struct * p_opptr, * p_pptr, * p_cptr, * p_ysptr, * p_osptr ;

  4. parent p_cptr p_pptr p_pptr p_pptr p_osptr p_osptr oldest child youngest child child p_ysptr p_ysptr

  5. volatile long state ; hardcoded #define TASK_RUNNING 0 #define TASK_INTERRUPTIBLE 1 #define TASK_UNINTERRUPTIBLE 2 #define TASK_ZOMBIE 4 #define TASK_STOPPED 8 #define TASK_SWAPPING 16

  6. unsigned long flags ; hardcoded #define PF_STARTING 0x00000002 /* being created */ #define PF_EXITING 0x00000004 /* getting shut down */ #define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called */ #define PF_TRACESYS 0x00000020 /* tracing system calls */ #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */ #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */ #define PF_DUMPCORE 0x00000200 /* dumped core */ #define PF_SIGNALED 0x00000400 /* killed by a signal */ #define PF_MEMALLOC 0x00000800 /* Allocating memory */

  7. Identifiers • pid_t pid ; • pid_t pgrp ; • pid_t session ; • int leader ; boolean value session process group process group process group

  8. uid_t uid, euid, suid, fsuid ; • gid_t gid, egid, sgid, fsgid ; • gid_t groups [NGROUPS] ; • int ngroups ;

  9. Scheduling 10ms, tick, jiffies • long counter ; • long priority ; • unsigned long policy, rt_priority ; • SCHED_OTHER • SCHED_FIFO • SCHED_RR weight = 1000 + p -> priority ; weight = p -> counter ; p -> counter = (p  counter / 2) + p -> priority ;

  10. struct thread_struct tss ; es

  11. SMP (Symmetric Multi-Processing) • int has_cpu ; • int processor ; • int last_processor ; • int lock_depth ; /* Lock depth. We can context switch in and out of holding a syscall kernel lock... */

  12. Files • struct fs_struct * fs ; • struct files_struct * files ;

  13. fs_struct inode task_struct inode files_struct file inode

  14. Virtual Memory • struct mm_struct * mm ; • demand paging • list, AVL tree

  15. vm_area_struct task_struct mm_struct Process Virtual Memory 0x8059BB8 vm_area_struct 0x8048000 0x0000000

  16. Time and Timers • Real SIGALRM • Virtual SIGVTALRM • Profile SIGPROF • unsigned long it_real_value, it_prof_value, it_virt_value ; • unsigned long it_real_incr, it_prof_incr, it_virt_incr ; • struct timer_list real_timer; • unsigned long start_time ; • struct tms times ;

  17. struct timer_list { struct timer_list * next ; struct timer_list * prev ; unsigned long expires ; unsigned long data ; void (* function) (unsigned long) ; } ; struct tms { clock_t tms_utime; clock_t tms_stime; clock_t tms_cutime; clock_t tms_cstime; };

  18. Execute Programs • struct linux_binfmt * binfmt ; format

  19. int exit_code, exit_signal ; • int dumpable:1 ; • int did_exec:1 ; • char comm [16] ; • struct rlimit rlim [RLIM_NLIMITS] ;

  20. struct rlimit { long rlim_cur ; long rlim_max ; } ; #define RLIMIT_CPU 0 /* CPU time in ms */ #define RLIMIT_FSIZE 1 /* Maximum filesize */ #define RLIMIT_DATA 2 /* max data size */ #define RLIMIT_STACK 3 /* max stack size */ #define RLIMIT_CORE 4 /* max core file size */ #define RLIMIT_RSS 5 /* max resident set size */ #define RLIMIT_NPROC 6 /* max number of processes */ #define RLIMIT_NOFILE 7 /* max number of open files */ #define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ #define RLIMIT_AS 9 /* address space limit */ #define RLIM_NLIMITS 10

  21. sigset_t signal, blocked ; • struct signal_struct * sig ; • struct sem_undo * semundo ; • struct sem_queue * semsleeping ; • struct wait_queue * wait_chldexit ; • struct semaphore * vfork_sem ;

  22. struct wait_queue { struct task_struct * task ; struct wait_queue * next ; } ; struct semaphore { atomic_t count ; int waking ; struct wait_queue * wait ; } ;

More Related