Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
 pthread_mutexattr_t attr;
 pthread_mutex_t mutex;
 size_t const shared_var = 0;

 int main(){
     int rc =0;

     rc = pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_NORMAL);
     if(rc != 0){
       /*Check Handle ReturnError Code*/
     }

     rc = pthread_mutex_init(&mutex, &attr);
     if(rc != 0){
       /*Check Handle ReturnError Code*/
     }


     pthread_mutex_lock(&mutex);

     /* Critical Region*/

     pthread_mutex_unlock(&mutex);

     return 0;
 }

...

Code Block
bgColor#ccccff
 pthread_mutexattr_t attr;
 pthread_mutex_t mutex;
 size_t const shared_var = 0;

 int main(){
     int rc =0;

     rc = pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_ERRORCHECK);
     if(rc != 0){
       /*Check Handle ReturnError Code*/
     }


     rc = pthread_mutex_init(&mutex, &attr);
     if(rc != 0){
       /*Check Handle ReturnError Code*/
     }


     rc = pthread_mutex_lock(&mutex);
     if(rc != 0){
       /* Handle error ifError any*/
     }

     /* Critical Region*/

     rc = pthread_mutex_unlock(&mutex);
     if(rc != 0){
       /* Handle errorError if any*/
     }


     return 0;
 }

Risk Assessment

...