Threading Issues A user presses a button on a web browser that stops a web page from loading any further: The thread accepting the user stop button press Wants the thread loading the page to be cancelled.
Signals, Messages Signals are used in UNIX systems to notify a process that a particular event has occurred A signal handler is used to process signals Signal is generated by particular event Signal is delivered to a process Signal is handled Every signal may be handled by one of two possible handlers: 1. A default signal handler 2. A user-defined signal handler
Signals generation, handling Unix Sending signals - kill(pid, SIGNAL) – send signal to other process (pid) Handling signals - signal(SIGNAL, handling_function); Windows WinAPI Sending signals – InvalidateRect(x,y,x1,y1) – send signal to repaint the part of window. Handling signals – case WM_PAINT {. . .}; or WM_... messages.
PThreads
Pthreads example
WinAPI Threads
Semantics of fork() and exec() Does fork() duplicate only the calling thread or all threads in multithreaded environment ? (Unix) There are two types of fork in different unix type systems: fork() – that duplicates the whole context fork() – that duplicates only a thread called the fork() exec() – works as before replacing the whole space by the new program. If exec is called immediately after forking, then duplicating all threads is unnecessary.
Threads Linux Threads