Advanced Programming in the UNIX Environment: Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Advanced Programming in the UNIX Environment: Second Edition [Electronic resources] - نسخه متنی

W. Richard Stevens; Stephen A. Rago

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



Exercises


11.1

Figure 11.4 to pass the structure between the threads properly.

11.2

Figure 11.13, what additional synchronization (if any) is necessary to allow the master thread to change the thread ID associated with a pending job? How would this affect the job_remove function?

11.3

Apply the techniques shown in Figure 11.14 to the worker thread example (Figure 11.1 and Figure 11.13) to implement the worker thread function. Don't forget to update the queue_init function to initialize the condition variable and change the the job_insert and job_append functions to signal the worker threads. What difficulties arise?

11.4

Which sequence of steps is correct?

  • Lock a mutex (pthread_mutex_lock).

  • Change the condition protected by the mutex.

  • Signal threads waiting on the condition (pthread_cond_broadcast).

  • Unlock the mutex (pthread_mutex_unlock).

  • or

  • Lock a mutex (pthread_mutex_lock).

  • Change the condition protected by the mutex.

  • Unlock the mutex (pthread_mutex_unlock).

  • Signal threads waiting on the condition (pthread_cond_broadcast).


    • / 369