Summer have come. I almost finished turning a thread into a process. In this case, there are many
problems I can not want before. The mutex lock is the first. Because of the descrepancy between the
mutex of threads and the semphare of processes. I have to bind a semphare to a share memory for convenience.
The second problem is a loop problem. In thread style, the communication between threads is used a global
variables in program. So, in original there are many global variables. The 'g_EndFlag' I must dealed with.
It tell a sub-thread when the logical loop end up. In my process, I have to turn to the signal mechanism.
When initializing the process, I registered a signal handler for SIGINT. So, when pressed Ctrl - C by user,
the signal handler modified the value of the 'g_EndFlag'. And the loop can terminated, the gotten resources,
such as share memory, semphore, etc. can be freed.