Lines Matching refs:threads
35 struct perf_thread_map *threads;
46 threads = thread_map__alloc(items);
47 if (threads != NULL) {
49 perf_thread_map__set_pid(threads, i, atoi(namelist[i]->d_name));
50 threads->nr = items;
51 refcount_set(&threads->refcnt, 1);
58 return threads;
63 struct perf_thread_map *threads = thread_map__alloc(1);
65 if (threads != NULL) {
66 perf_thread_map__set_pid(threads, 0, tid);
67 threads->nr = 1;
68 refcount_set(&threads->refcnt, 1);
71 return threads;
80 struct perf_thread_map *threads = thread_map__alloc(max_threads);
82 if (threads == NULL)
89 threads->nr = 0;
90 refcount_set(&threads->refcnt, 1);
114 while (threads->nr + items >= max_threads) {
122 tmp = perf_thread_map__realloc(threads, max_threads);
126 threads = tmp;
130 perf_thread_map__set_pid(threads, threads->nr + i,
138 threads->nr += items;
144 return threads;
147 free(threads);
156 zfree(&threads);
183 struct perf_thread_map *threads = NULL, *nt;
213 nt = perf_thread_map__realloc(threads, total_tasks);
217 threads = nt;
220 perf_thread_map__set_pid(threads, j++, atoi(namelist[i]->d_name));
223 threads->nr = total_tasks;
229 if (threads)
230 refcount_set(&threads->refcnt, 1);
231 return threads;
239 zfree(&threads);
245 struct perf_thread_map *threads = NULL, *nt;
253 /* perf-stat expects threads to be generated even if tid not given */
272 nt = perf_thread_map__realloc(threads, ntasks);
277 threads = nt;
278 perf_thread_map__set_pid(threads, ntasks - 1, tid);
279 threads->nr = ntasks;
282 if (threads)
283 refcount_set(&threads->refcnt, 1);
284 return threads;
287 zfree(&threads);
307 size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp)
311 threads->nr, threads->nr > 1 ? "s" : "");
312 for (i = 0; i < threads->nr; ++i)
313 printed += fprintf(fp, "%s%d", i ? ", " : "", perf_thread_map__pid(threads, i));
363 void thread_map__read_comms(struct perf_thread_map *threads)
367 for (i = 0; i < threads->nr; ++i)
368 comm_init(threads, i);
371 static void thread_map__copy_event(struct perf_thread_map *threads,
376 threads->nr = (int) event->nr;
379 perf_thread_map__set_pid(threads, i, (pid_t) event->entries[i].pid);
380 threads->map[i].comm = strndup(event->entries[i].comm, 16);
383 refcount_set(&threads->refcnt, 1);
388 struct perf_thread_map *threads;
390 threads = thread_map__alloc(event->nr);
391 if (threads)
392 thread_map__copy_event(threads, event);
394 return threads;
397 bool thread_map__has(struct perf_thread_map *threads, pid_t pid)
401 for (i = 0; i < threads->nr; ++i) {
402 if (threads->map[i].pid == pid)
409 int thread_map__remove(struct perf_thread_map *threads, int idx)
413 if (threads->nr < 1)
416 if (idx >= threads->nr)
422 zfree(&threads->map[idx].comm);
424 for (i = idx; i < threads->nr - 1; i++)
425 threads->map[i] = threads->map[i + 1];
427 threads->nr--;