Lines Matching refs:threads

57 	struct thread_map *threads;  in thread_map__new_by_pid()  local
68 threads = thread_map__alloc(items); in thread_map__new_by_pid()
69 if (threads != NULL) { in thread_map__new_by_pid()
71 thread_map__set_pid(threads, i, atoi(namelist[i]->d_name)); in thread_map__new_by_pid()
72 threads->nr = items; in thread_map__new_by_pid()
73 refcount_set(&threads->refcnt, 1); in thread_map__new_by_pid()
80 return threads; in thread_map__new_by_pid()
85 struct thread_map *threads = thread_map__alloc(1); in thread_map__new_by_tid() local
87 if (threads != NULL) { in thread_map__new_by_tid()
88 thread_map__set_pid(threads, 0, tid); in thread_map__new_by_tid()
89 threads->nr = 1; in thread_map__new_by_tid()
90 refcount_set(&threads->refcnt, 1); in thread_map__new_by_tid()
93 return threads; in thread_map__new_by_tid()
102 struct thread_map *threads = thread_map__alloc(max_threads); in __thread_map__new_all_cpus() local
104 if (threads == NULL) in __thread_map__new_all_cpus()
111 threads->nr = 0; in __thread_map__new_all_cpus()
112 refcount_set(&threads->refcnt, 1); in __thread_map__new_all_cpus()
136 while (threads->nr + items >= max_threads) { in __thread_map__new_all_cpus()
144 tmp = thread_map__realloc(threads, max_threads); in __thread_map__new_all_cpus()
148 threads = tmp; in __thread_map__new_all_cpus()
152 thread_map__set_pid(threads, threads->nr + i, in __thread_map__new_all_cpus()
160 threads->nr += items; in __thread_map__new_all_cpus()
166 return threads; in __thread_map__new_all_cpus()
169 free(threads); in __thread_map__new_all_cpus()
178 zfree(&threads); in __thread_map__new_all_cpus()
205 struct thread_map *threads = NULL, *nt; in thread_map__new_by_pid_str() local
235 nt = thread_map__realloc(threads, total_tasks); in thread_map__new_by_pid_str()
239 threads = nt; in thread_map__new_by_pid_str()
242 thread_map__set_pid(threads, j++, atoi(namelist[i]->d_name)); in thread_map__new_by_pid_str()
245 threads->nr = total_tasks; in thread_map__new_by_pid_str()
251 if (threads) in thread_map__new_by_pid_str()
252 refcount_set(&threads->refcnt, 1); in thread_map__new_by_pid_str()
253 return threads; in thread_map__new_by_pid_str()
261 zfree(&threads); in thread_map__new_by_pid_str()
267 struct thread_map *threads = thread_map__alloc(1); in thread_map__new_dummy() local
269 if (threads != NULL) { in thread_map__new_dummy()
270 thread_map__set_pid(threads, 0, -1); in thread_map__new_dummy()
271 threads->nr = 1; in thread_map__new_dummy()
272 refcount_set(&threads->refcnt, 1); in thread_map__new_dummy()
274 return threads; in thread_map__new_dummy()
279 struct thread_map *threads = NULL, *nt; in thread_map__new_by_tid_str() local
306 nt = thread_map__realloc(threads, ntasks); in thread_map__new_by_tid_str()
311 threads = nt; in thread_map__new_by_tid_str()
312 thread_map__set_pid(threads, ntasks - 1, tid); in thread_map__new_by_tid_str()
313 threads->nr = ntasks; in thread_map__new_by_tid_str()
316 if (threads) in thread_map__new_by_tid_str()
317 refcount_set(&threads->refcnt, 1); in thread_map__new_by_tid_str()
318 return threads; in thread_map__new_by_tid_str()
321 zfree(&threads); in thread_map__new_by_tid_str()
341 static void thread_map__delete(struct thread_map *threads) in thread_map__delete() argument
343 if (threads) { in thread_map__delete()
346 WARN_ONCE(refcount_read(&threads->refcnt) != 0, in thread_map__delete()
348 for (i = 0; i < threads->nr; i++) in thread_map__delete()
349 free(thread_map__comm(threads, i)); in thread_map__delete()
350 free(threads); in thread_map__delete()
367 size_t thread_map__fprintf(struct thread_map *threads, FILE *fp) in thread_map__fprintf() argument
371 threads->nr, threads->nr > 1 ? "s" : ""); in thread_map__fprintf()
372 for (i = 0; i < threads->nr; ++i) in thread_map__fprintf()
373 printed += fprintf(fp, "%s%d", i ? ", " : "", thread_map__pid(threads, i)); in thread_map__fprintf()
423 void thread_map__read_comms(struct thread_map *threads) in thread_map__read_comms() argument
427 for (i = 0; i < threads->nr; ++i) in thread_map__read_comms()
428 comm_init(threads, i); in thread_map__read_comms()
431 static void thread_map__copy_event(struct thread_map *threads, in thread_map__copy_event() argument
436 threads->nr = (int) event->nr; in thread_map__copy_event()
439 thread_map__set_pid(threads, i, (pid_t) event->entries[i].pid); in thread_map__copy_event()
440 threads->map[i].comm = strndup(event->entries[i].comm, 16); in thread_map__copy_event()
443 refcount_set(&threads->refcnt, 1); in thread_map__copy_event()
448 struct thread_map *threads; in thread_map__new_event() local
450 threads = thread_map__alloc(event->nr); in thread_map__new_event()
451 if (threads) in thread_map__new_event()
452 thread_map__copy_event(threads, event); in thread_map__new_event()
454 return threads; in thread_map__new_event()
457 bool thread_map__has(struct thread_map *threads, pid_t pid) in thread_map__has() argument
461 for (i = 0; i < threads->nr; ++i) { in thread_map__has()
462 if (threads->map[i].pid == pid) in thread_map__has()
469 int thread_map__remove(struct thread_map *threads, int idx) in thread_map__remove() argument
473 if (threads->nr < 1) in thread_map__remove()
476 if (idx >= threads->nr) in thread_map__remove()
482 free(threads->map[idx].comm); in thread_map__remove()
484 for (i = idx; i < threads->nr - 1; i++) in thread_map__remove()
485 threads->map[i] = threads->map[i + 1]; in thread_map__remove()
487 threads->nr--; in thread_map__remove()