Liunx获取线程Id
来源:互联网 发布:千县万村农村淘宝计划 编辑:程序博客网 时间:2024/05/16 05:45
- 获取进程的id
#include <unistd.h>pid_t getpid(void);
- 获取线程的id
需要系统调用值:
#define __NR_gettid 224
获取某个线程的id的方法:
cout << "this tread is: " << (long int)syscall(224);
比较好的方式是
#define __NR_gettid 224#define gettid1() syscall( __NR_gettid)#define gettid2() syscall( SYS_gettid)cout << "this tread is: " << gettid1();cout << "this tread is: " << gettid2();
// /usr/include/bits/syscall.h #define SYS_gettid __NR_gettid #ifndef _LIBC /* The Linux kernel header file defines macros `__NR_<name>', but some programs expect the traditional form `SYS_<name>'. So in building libc we scan the kernel's list and produce <bits/syscall.h> with macros for all the `SYS_' names. */ # include <bits/syscall.h> #endif
查看进程pid
(1) ps ux | grep prog_name
(2) pgrep prog_name
查看线程tid
(1) ps -efL | grep prog_name
(2) ls /proc/pid/task
阅读全文
0 0
- Liunx获取线程Id
- Linux获取线程ID
- 获取线程ID
- 获取线程ID
- 获取线程ID
- 3.4 线程id获取
- linux获取线程ID
- linux下获取线程id
- linux 下获取线程ID
- linux多线程,获取线程ID
- 获取当前进程ID和子线程的线程ID
- gettid()获取线程ID测试程序
- linux 获取线程ID的方法
- 获取进程和线程id函数简介
- linux 获取线程ID的方法
- 获取当前线程的id号 gettid()
- 根据线程ID获取其Handle
- 获取线程id的另一种方法
- linux gpio 控制 基于 sysfs
- 堆和栈的区别
- Notepad++文本比较插件:Compare
- Java设计模式——工厂设计模式
- java中Object.equals()和==以及字符串.equals()
- Liunx获取线程Id
- java.lang.OutOfMemoryError:GC overhead limit exceeded填坑心得
- Java面试系列
- Assign the task
- js DOM
- ONENET平台简介及简单的接入方法
- 线性代数1-矩阵基础
- 在博客中使用LaTeX插入数学公式
- HTML中使用Ajax进行局部刷新页面