The purpose of the buffer is to reduce jitter in the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: outine, which runs in the context of the main thread. In line 7, the main routine declares a single local variable tid, which will be used to store the thread ID of the peer thread. In line 9, the main thread creates a new peer thread by calling the pthread create function.1 When the call to pthread create returns, the main thread and the newly created thread are running 1 We are actually calling an error-handling wrapper, which were introduced in Section 8.3 and described in detail in Appendix A. 11.2. THREAD CONTROL 567 concurrently, and tid contains the ID of the new thread. In line 10, the main thread waits for the newly created thread to terminate. Finally, in line 11, the main thread terminates itself and the entire process by calling exit. Lines 15–19 define the thread routine, which in this case simply prints a string then terminates by executing the return statement in line 18. 11.2.1 Creating Threads Threads create other threads by calling the pthread create function. #include <pthread.h> typedef void *(func)(void *); int pthread create(pthread t *tid, pthread a...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online