A signal handler is used to process signals 1 signal

Info icon This preview shows pages 22–27. Sign up to view the full content.

signal handler   is used to process signals 1. Signal is generated by particular event 2. Signal is delivered to a process 3. Signal is handled by one of two signal handlers: 1. default 2. user-defined Every signal has  default handler  that kernel runs when  handling signal User-defined signal handler  can override default For single-threaded, signal delivered to process
Image of page 22

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

4.23 Silberschatz, Galvin and Gagne  © 2013 Operating System Concepts – 9 th  Edition Thread Cancellation Terminating a thread before it has finished Thread to be canceled is  target thread Two general approaches: Asynchronous cancellation  terminates the target thread  immediately Deferred cancellation  allows the target thread to periodically  check if it should be cancelled Pthread code to create and cancel a thread:
Image of page 23
4.24 Silberschatz, Galvin and Gagne  © 2013 Operating System Concepts – 9 th  Edition Thread Cancellation (Cont.) Invoking thread cancellation requests cancellation, but actual  cancellation depends on thread state If thread has cancellation disabled, cancellation remains pending  until thread enables it Default type is deferred Cancellation only occurs when thread reaches  cancellation  point I.e.  pthread_testcancel() Then  cleanup handler  is invoked On Linux systems, thread cancellation is handled through signals
Image of page 24

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

4.25 Silberschatz, Galvin and Gagne  © 2013 Operating System Concepts – 9 th  Edition Thread-Local Storage Thread-local storage  ( TLS ) allows each thread to have its  own copy of data Useful when you do not have control over the thread creation  process (i.e., when using a thread pool) Different from local variables Local variables visible only during single function  invocation TLS visible across function invocations Similar to  static  data TLS is unique to each thread
Image of page 25
4.26 Silberschatz, Galvin and Gagne  © 2013 Operating System Concepts – 9 th  Edition Operating System Examples Windows Threads Linux Threads
Image of page 26

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

4.27 Silberschatz, Galvin and Gagne  © 2013 Operating System Concepts – 9 th  Edition Linux Threads Linux refers to them as  tasks  rather than  threads Thread creation is done through  clone() system call clone() allows a child task to share the address space of the  parent task (process) Flags control behavior struct task_struct points to process data structures  (shared or unique)
Image of page 27
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '16
  • Gagne, Galvin, Silberschatz

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern