Why would you optimize the mutex ?

sleep(1/2); ==> doesn't work , because 1/2 is cast to 0.

On Thu, Sep 3, 2020 at 9:25 AM Niresh <[email protected]> wrote:

> Hi,
>
> I am using beagle Bone Black with debian image. Could any please suggest
> how to optimize the application code using pthread_mutex_lock. Let me
> describe the solution I am looking at.
>
> For example, I have two thread sharing a global shared memory variable as
> below
>
> thr_id1 = pthread_create ( &p_thread1, NULL, (void *)execution_task1, NULL
> );
> thr_id2 = pthread_create ( &p_thread2, NULL, (void *)execution_task2, NULL
> );
>
> void execution_task1()
> {
>
>      for(int i = 0;i < 100;i++)
>      {
>           pthread_mutex_lock(&lock);
>                 shmPtr->status = 1;
> pthread_mutex_unlock(&lock);
> sleep(1/2);
>      }
> }
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/fe4074cd-ff97-4e7c-8d68-02ba9a0d5678n%40googlegroups.com
> <https://groups.google.com/d/msgid/beagleboard/fe4074cd-ff97-4e7c-8d68-02ba9a0d5678n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CAF%2BMRtk95cuAO3NteqTaVBp9Drd%2B5waKT9BjGEYYdnD9Oz-E3A%40mail.gmail.com.

Reply via email to