Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Help with multithreading

$
0
0
I take this question of the The Linux Programming Interface:
Code:

A Linux and Unix System Programming page 652 exercise 30.1
I want someone to explain the under line statement because it sounds complex to me couldn't understand anything

30-1 Modify the program (thread_incr.c) so that each loop in the thread’s start function outputs the current value of glob and some identifier that uniquely identifies the thread.

Code:

The unique identifier for the thread could be specified as an argument to the pthread_create()
call used to create the thread. For this program, that would require changing the argument
of the thread’s start function to be a pointer to a structure containing the unique identifier
and a loop limit value.

Run the program, redirecting output to a file, and then inspect the
file to see what happens to glob as the kernel scheduler alternates execution between the
two threads.

Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images