Lines Matching refs:threads

36 	struct perf_thread_map *threads;
47 threads = thread_map__alloc(items);
48 if (threads != NULL) {
50 perf_thread_map__set_pid(threads, i, atoi(namelist[i]->d_name));
51 threads->nr = items;
52 refcount_set(&threads->refcnt, 1);
59 return threads;
64 struct perf_thread_map *threads = thread_map__alloc(1);
66 if (threads != NULL) {
67 perf_thread_map__set_pid(threads, 0, tid);
68 threads->nr = 1;
69 refcount_set(&threads->refcnt, 1);
72 return threads;
81 struct perf_thread_map *threads = thread_map__alloc(max_threads);
83 if (threads == NULL)
90 threads->nr = 0;
91 refcount_set(&threads->refcnt, 1);
115 while (threads->nr + items >= max_threads) {
123 tmp = perf_thread_map__realloc(threads, max_threads);
127 threads = tmp;
131 perf_thread_map__set_pid(threads, threads->nr + i,
139 threads->nr += items;
145 return threads;
148 free(threads);
157 zfree(&threads);
184 struct perf_thread_map *threads = NULL, *nt;
214 nt = perf_thread_map__realloc(threads, total_tasks);
218 threads = nt;
221 perf_thread_map__set_pid(threads, j++, atoi(namelist[i]->d_name));
224 threads->nr = total_tasks;
230 if (threads)
231 refcount_set(&threads->refcnt, 1);
232 return threads;
240 zfree(&threads);
246 struct perf_thread_map *threads = NULL, *nt;
254 /* perf-stat expects threads to be generated even if tid not given */
273 nt = perf_thread_map__realloc(threads, ntasks);
278 threads = nt;
279 perf_thread_map__set_pid(threads, ntasks - 1, tid);
280 threads->nr = ntasks;
284 if (threads)
285 refcount_set(&threads->refcnt, 1);
286 return threads;
289 zfree(&threads);
308 size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp)
312 threads->nr, threads->nr > 1 ? "s" : "");
313 for (i = 0; i < threads->nr; ++i)
314 printed += fprintf(fp, "%s%d", i ? ", " : "", perf_thread_map__pid(threads, i));
364 void thread_map__read_comms(struct perf_thread_map *threads)
368 for (i = 0; i < threads->nr; ++i)
369 comm_init(threads, i);
372 static void thread_map__copy_event(struct perf_thread_map *threads,
377 threads->nr = (int) event->nr;
380 perf_thread_map__set_pid(threads, i, (pid_t) event->entries[i].pid);
381 threads->map[i].comm = strndup(event->entries[i].comm, 16);
384 refcount_set(&threads->refcnt, 1);
389 struct perf_thread_map *threads;
391 threads = thread_map__alloc(event->nr);
392 if (threads)
393 thread_map__copy_event(threads, event);
395 return threads;
398 bool thread_map__has(struct perf_thread_map *threads, pid_t pid)
402 for (i = 0; i < threads->nr; ++i) {
403 if (threads->map[i].pid == pid)
410 int thread_map__remove(struct perf_thread_map *threads, int idx)
414 if (threads->nr < 1)
417 if (idx >= threads->nr)
423 zfree(&threads->map[idx].comm);
425 for (i = idx; i < threads->nr - 1; i++)
426 threads->map[i] = threads->map[i + 1];
428 threads->nr--;