×‍×¢×¨×›×•× ×”×¤×¢×œ×” ×רגול 6 – חו××™×‌ ב-Linux. ×‍×¢×¨×›×•× ×”×¤×¢×œ×” - ×רגול

  • View
    251

  • Download
    0

Embed Size (px)

Text of ×‍ערכו×...

  • Slide 1
  • 6 -Linux
  • Slide 2
  • - 62 (c) 2003 -Linux Linux -Linux -Linux Linux Threads POSIX Threads API fork() : Linux
  • Slide 3
  • - 63 (c) 2003 -Linux (1) . -Linux : , , . .
  • Slide 4
  • - 64 (c) 2003 -Linux (2) . . .
  • Slide 5
  • - 65 (c) 2003 -Linux (3) , (primary thread), clone(). : . : - , , '.
  • Slide 6
  • - 66 (c) 2003 -Linux (4) : , . -: . "" , -: . : : . : .
  • Slide 7
  • - 67 (c) 2003 Linux (1) Linux . , . -Linux Unix POSIX Threads POSIX 1003.1c , , -PID . , , POSIX, PID . -PID getpid() PID
  • Slide 8
  • - 68 (c) 2003 Linux (2) , Linux ( 2.4.X ) (thread group): . thread_group . tgid -PID . , -PID . getpid() current->tgid. -PID -PID. (), .
  • Slide 9
  • - 69 (c) 2003 clone() (1) clone() user mode : int clone(int (*fn)(void*), void *child_stack, int flags, void *arg); : fn . fn(arg) , child_stack : Linux
  • Slide 10
  • - 610 (c) 2003 clone() (2) flags (OR) . : arg fn() . : , -PID , -1. Linux CLONE_VM CLONE_FILES , CLONE_FS ( ) CLONE_PARENT ( tgid). CLONE_PARENT CLONE_THREAD
  • Slide 11
  • - 611 (c) 2003 clone() (3) , sys_clone() ( arch/i386/kernel/process.c) do_fork() , - . -Linux, -clone(). Linux
  • Slide 12
  • - 612 (c) 2003 -Linux -Linux Linux Threads. ( , ) POSIX Threads. , PID - getpid(). Linux Threads 2.4.X , ( ) .
  • Slide 13
  • - 613 (c) 2003 -Linux: Linux Threads , , Kernel Threads/Lightweight Processes)) , " . : NPTL (Native POSIX Thread Library) -POSIX Threads -Linux Threads , Linux Threads .
  • Slide 14
  • - 614 (c) 2003 POSIX Threads -POSIX Threads -Linux Threads : (C) #include pthread, : gcc g o myprog myprog.c lpthread Linux Threads : POSIX Threads API , -wrapper functions
  • Slide 15
  • - 615 (c) 2003 POSIX Threads API (1) : pthread_create() - . start_routine . : int pthread_create(pthread_t *thread, pthread_attr_t *attr, void* (*start_routine)(void*), void *arg); : 0 , . , " thread.
  • Slide 16
  • - 616 (c) 2003 POSIX Threads API (2) : thread . attr , , join, , '. " NULL . start_routine . . arg .
  • Slide 17
  • - 617 (c) 2003 POSIX Threads API (3) :pthread_exit() - . . : void pthread_exit(void *retval); : retval ( exit()) : " pthread_exit() .
  • Slide 18
  • - 618 (c) 2003 POSIX Threads API (4) : -pthread_exit() -exit() " ( "" ) " -pthread_cancel()
  • Slide 19
  • - 619 (c) 2003 POSIX Threads API (5) : pthread_self() - . Linux Threads -PID . : pthread_t pthread_self(); : :
  • Slide 20
  • - 620 (c) 2003 POSIX Threads API (6) : pthread_join() - " th. : int pthread_join(pthread_t th, void **thread_return); : th " " -wait(). thread_return NULL
  • Slide 21
  • - 621 (c) 2003 POSIX Threads API (7) : 0 , -0 . , -thread_return ( NULL). : pthread_join Linux Threads
  • Slide 22
  • - 622 (c) 2003 POSIX Threads API (8) : pthread_cancel() - " thread. PTHREAD_CANCELED : int pthread_cancel(pthread_t thread); : thread : 0 ,
  • Slide 23
  • - 623 (c) 2003 fork() -fork(), wait() . , , wait() , -Linux Threads
  • Slide 24
  • - 624 (c) 2003 execv() -execv() , : ' -Linux Threads
  • Slide 25
  • - 625 (c) 2003 -exit() -, , , exit() pthread_exit(), -Linux Threads
  • Slide 26
  • - 626 (c) 2003 Control Paths (, ) (). (kernel control path). - user mode -system_call() - ret_from_sys_call(). descriptor , .
  • Slide 27
  • - 627 (c) 2003 , : . - , . , , . , " .
  • Slide 28
  • - 628 (c) 2003 - ? - , , . ( ) , " . ( page fault), . . : 1. -schedule. 2. .
  • Slide 29
  • - 629 (c) 2003 . " . ...
  • Slide 30
  • - 630 (c) 2003 : (atomic operations): (read-modify-write) . . , lock (IA32) (memory bus) . : test_and_set_bit(),
  • Slide 31
  • - 631 (c) 2003 : (Local Interrupt Disabling): " , .
  • Slide 32
  • - 632 (c) 2003 : : . , ( ) struct semaphore include/asm-i386/semaphore.h
  • Slide 33
  • - 633 (c) 2003 . , Spin Lock - , -busy wait. , , -spin lock , . , busy wait , . spinlock_t include/linux/spinlock.h
  • Slide 34
  • - 634 (c) 2003 : Addition for Multi- processor protection Uni-processor protection Kernel control paths accessing the data structure NoneSemaphoreExceptions Spin lockLocal interrupt disabling Interrupts Spin lockLocal interrupt disabling Exception+Interrupt

View more >