File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -359,24 +359,14 @@ static uint32_t read_lock_acquire(struct posix_rwlock *rwl, uint32_t timeout)
359359static uint32_t write_lock_acquire (struct posix_rwlock * rwl , uint32_t timeout )
360360{
361361 uint32_t ret = 0U ;
362- int64_t elapsed_time , st_time = k_uptime_get ();
363- k_timeout_t k_timeout ;
362+ k_timepoint_t deadline ;
364363
365- k_timeout = SYS_TIMEOUT_MS (timeout );
364+ deadline = sys_timepoint_calc ( SYS_TIMEOUT_MS (timeout ) );
366365
367366 /* waiting for release of write lock */
368- if (sys_sem_take (& rwl -> wr_sem , k_timeout ) == 0 ) {
369- /* update remaining timeout time for 2nd sem */
370- if (timeout != SYS_FOREVER_MS ) {
371- elapsed_time = k_uptime_get () - st_time ;
372- timeout = timeout <= elapsed_time ? 0 :
373- timeout - elapsed_time ;
374- }
375-
376- k_timeout = SYS_TIMEOUT_MS (timeout );
377-
367+ if (sys_sem_take (& rwl -> wr_sem , sys_timepoint_timeout (deadline )) == 0 ) {
378368 /* waiting for reader to complete operation */
379- if (sys_sem_take (& rwl -> reader_active , k_timeout ) == 0 ) {
369+ if (sys_sem_take (& rwl -> reader_active , sys_timepoint_timeout ( deadline ) ) == 0 ) {
380370 rwl -> wr_owner = k_current_get ();
381371 } else {
382372 (void )sys_sem_give (& rwl -> wr_sem );
You can’t perform that action at this time.
0 commit comments