May 29th Tuesday (五月 二十九日 火曜日)

来源:互联网 发布:java语言和c语言的区别 编辑:程序博客网 时间:2024/04/30 23:39

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. 

原创粉丝点击