Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/syscall.h>
- #include <pthread.h>
- #include <unistd.h>
- void * thread(void *arg)
- {
- sleep(1);
- printf("T self: %lu\n", pthread_self());
- printf("T tid: %lu\n", syscall(SYS_gettid));
- printf("T pid: %u\n", getpid());
- sleep(2);
- return 0;
- }
- int main()
- {
- pthread_t tid;
- pthread_create(&tid, NULL, thread, NULL);
- printf("Started thread: %lu\n", tid);
- printf("M self: %lu\n", pthread_self());
- printf("M tid: %lu\n", syscall(SYS_gettid));
- printf("M pid: %u\n", getpid());
- pthread_join(tid, NULL);
- return 0;
- }
Add Comment
Please, Sign In to add comment