Skip to content

Commit

Permalink
sched/clock: remove unlock logic to avoid relock
Browse files Browse the repository at this point in the history
get time spec before protect g_basetime

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao authored and acassis committed Jan 13, 2025
1 parent a9ec6e9 commit 5dedc01
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sched/clock/clock_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ static void clock_inittime(FAR const struct timespec *tp)
struct timespec ts;
irqstate_t flags;

clock_systime_timespec(&ts);

flags = spin_lock_irqsave(&g_basetime_lock);
if (tp)
{
Expand All @@ -173,12 +175,6 @@ static void clock_inittime(FAR const struct timespec *tp)
clock_basetime(&g_basetime);
}

spin_unlock_irqrestore(&g_basetime_lock, flags);

clock_systime_timespec(&ts);

flags = spin_lock_irqsave(&g_basetime_lock);

/* Adjust base time to hide initial timer ticks. */

g_basetime.tv_sec -= ts.tv_sec;
Expand Down

0 comments on commit 5dedc01

Please sign in to comment.