Ayah Kashkoul commented on a discussion on 
testsuites/psxtests/psxmsgq_prio_wakeup/init.c: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1084#note_144120

 > +    printf( "mq_open failed: %s\n", strerror( errno ) );
 > +    goto cleanup_sems;
 > +  }
 > +
 > +  /* 3. Create low priority thread 1 (id=1) */
 > +  pthread_attr_init( &pattr );
 > +  pthread_attr_setinheritsched( &pattr, PTHREAD_EXPLICIT_SCHED );
 > +  pthread_attr_setschedpolicy( &pattr, SCHED_FIFO );
 > +  sparam.sched_priority = low_prio;
 > +  pthread_attr_setschedparam( &pattr, &sparam );
 > +  rc = pthread_create( &tid1, &pattr, receive_thread, &id1 );
 > +  if ( rc != 0 ) {
 > +    printf( "Failed to create thread 1: %s\n", strerror( rc ) );
 > +    goto cleanup;
 > +  }
 > +  usleep( 10000 );

@gedare @aptacc2421 Good point. @aptacc2421's usleep() calls were originally 
used to ensure threads had time to block before mq_send(), but they introduce 
unnecessary delays and timing dependencies.

In !1098 I removed usleep() and replaced it with semaphore-based 
synchronization so the test deterministically waits for each thread to reach 
the blocking point before sending. This eliminates race conditions and reduces 
runtime. Let me know what you think :)

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1084#note_144120
You're receiving this email because of your account on gitlab.rtems.org.


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to