POSIX thread programming
Introduction: Using thread has many benefits. They share the same resources of their calling process (parent process), like global variables, open files and so on. Also they have their own thread ID, stacks, and so on. For more information, please refer to the old article "Multitasking in Embedded Linux" and reference [1]. Here we focus on how to use it. The simplest thread programming: #include <stdio.h> #include <stdlib.h> #include <pthread.h> void *print_message(void *ptr) { char *text; text=(char *)ptr; printf("%s \n", text); } main() { pthread_t thread1, thread2; char *str1="I am thread1"; char *str2="I am thread2"; int T1ret, T2ret; /*Create two threads*/ T1ret=pthread_create(&thread1, NULL, print_message, (void*) str1); T2ret=pthread_create(...