1. Trang chủ
  2. » Luận Văn - Báo Cáo

Project spotlights

20 112 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Each process has its own address space. Therefore, individual processes cannot communicate unlike threads. • Interprocess communication: Linux/Unix provides several ways to allow communications

Outline Review Inter process communication Signals Fork Pipes FIFO Spotlights 1 6.087 Lecture 14 – January 29, 2010 Review Inter process communication Signals Fork Pipes FIFO Spotlights 2 Review: multithreading Race conditions • non-determinism in thread order. • • can be prevented by synchronization • atomic operations necessary for synchronization • Mutex: Allows a single thread to own it • Semaphores: Generalization of mutex, allows N threads to acquire it at a time. • P(s) : acquires a lock • V(s) : releases lock • sem_init(),sem_destroy() • sem_wait(),sem_trywait(),sem_post() • Other problems: deadlock, starvation 2 Sockets • <sys/socket.h> • enables client-server computing • Client: connect() • Server: bind(),listen(),accept() • I/O: write(),send(),read(),recv() 3 6.087 Lecture 14 – January 29, 2010 Review Inter process communication Signals Fork Pipes FIFO Spotlights 4 Preliminaries • Each process has its own address space. Therefore, individual processes cannot communicate unlike threads. • Interprocess communication: Linux/Unix provides several ways to allow communications • signal • pipes • FIFO queues • shared memory • semaphores sockets • 4 <signals.h> • Unix/Linux allows us to handle exceptions that arise during execution (e.g., interrupt, floating point error, segmentation fault etc.). • A process recieves a signal when such a condition occurs. void (∗signal( int sig ,void(∗handler)(int )))( int ) • determines how subsequent signals will be handled. • pre-defined behavior: SIG_DFL (default), SIG_IGN (ignore) • returns the previous handler. 5 <signal.h> Valid signals: SIGABRT abnormal termination SIGFPE floating point error SIGILL illegal instruction SIGINT interrupt SIGSEGV segmentation fault SIGTERM termination request SIGBUS bus error SIGQUIT quit The two signals SIGSTOP,SIGKILL cannot be handled. 6 <signal.h> int raise( int sig) can be used to send signal sig to the program. Notes: There can be race conditions. • • signal handler itself can be interrupted. use of non-reentrant functions unsafe. • • sigprocmask can be used to prevent interruptions. handler is reset each time it is called. • 7 Example #i nclud e < s t d i o . h> void s i g p r o c ( ) { s i g na l ( SIGINT , s i g p r o c ) ; / ∗ ∗/ p r i n t f ( " you have pressed c t r l −c \ n " ) ; } void q u it pr oc ( ) { p r i n t f ( " c t r l −\\ pr essed to q u i t " ) ; e x i t ( 0 ) ; / ∗ normal e x i t s t a t us ∗ / } main ( ) { s i g na l ( SIGINT , s i g p r o c ) ; s i g na l ( SIGQUIT , q u i tp ro c ) ; p r i n t f ( ‘ ‘ c t r l −c d i s a b l e d use c t r l −\\ t o q ui t n ’ ’ ) ; for ( ; ; ) ; / ∗ i n f i n i t e l oo p ∗ / } 8 [...]... ( " w r i t e " ) ; else p r i n t f ( " wrote %d b y t e s \ n " , num ) ; } return 0; } } 15 6.087 Lecture 14 – January 29, 2010 Review Inter process communication Signals Fork Pipes FIFO Spotlights 16 Project spotlights • Face finding with openCV • Barcode scanner • ImageIC • Image2DXF • Library database • Simple Audio Visualizer • Non-linear oscillator • NoteDeluxe • CUDA • Visual mouse • Wallpaper

Ngày đăng: 25/04/2013, 08:07

Xem thêm: Project spotlights

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w