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);
116 while (threads->nr + items >= max_threads) {
124 tmp = perf_thread_map__realloc(threads, max_threads);
128 threads = tmp;
132 perf_thread_map__set_pid(threads, threads->nr + i,
140 threads->nr += items;
146 return threads;
149 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;
283 if (threads)
284 refcount_set(&threads->refcnt, 1);
285 return threads;
288 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--;