216 for (i = 0; i < NUM_PHILS; i++) {
217
218 /*
219 * 1. Store the stat filename for this diner into a buffer. Use the sprintf
220 * library call.
221 */
222 if(sprintf(filename,"/proc/self/task/%d/stat",diners[i].tid) < 0){
223 printf("Could not convert thread stat file name of thread %d",diners[i].tid);
224 }
225
226
227 /*
228 * 2. Use fopen to open the stat file as a file stream. Open it
229 * with read only permissions.
230 */
231 statf = fopen(filename,"r");
232 if (statf ==NULL){
233 printf("Could not open thread stat file name of thread %d",diners[i].tid);
234 }
235
236 /*
237 * 3. Seek over uninteresting fields. Use fscanf to perform the seek. You
238 * also need to determine how many fields to skip over - see proc(5)
239 * HINT: Use the the * qualifier to skip tokens without storing them.
240 */
241 for (i = 0; i < 13; i++){
242 fscanf(statf,"\n%*s");
243 }