xiaoxiang781216 commented on code in PR #8619: URL: https://github.com/apache/nuttx/pull/8619#discussion_r1115286201
########## drivers/note/note_driver.c: ########## @@ -223,31 +223,55 @@ static void note_common(FAR struct tcb_s *tcb, FAR struct note_common_s *note, uint8_t length, uint8_t type) { -#ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES struct timespec ts; - +#ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES clock_systime_timespec(&ts); #else clock_t systime = clock_systime_ticks(); +# ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT + uint32_t count = up_perf_gettime(); +# endif #endif /* Save all of the common fields */ note->nc_length = length; note->nc_type = type; - note->nc_priority = tcb->sched_priority; + + if (tcb == NULL) + { + note->nc_priority = CONFIG_INIT_PRIORITY; #ifdef CONFIG_SMP - note->nc_cpu = tcb->cpu; + note->nc_cpu = 0; #endif - sched_note_flatten(note->nc_pid, &tcb->pid, sizeof(tcb->pid)); + memset(note->nc_pid, 0, sizeof(tcb->pid)); + } + else + { + note->nc_priority = tcb->sched_priority; +#ifdef CONFIG_SMP + note->nc_cpu = tcb->cpu; +#endif + sched_note_flatten(note->nc_pid, &tcb->pid, sizeof(tcb->pid)); + } #ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES sched_note_flatten(note->nc_systime_nsec, &ts.tv_nsec, sizeof(ts.tv_nsec)); sched_note_flatten(note->nc_systime_sec, &ts.tv_sec, sizeof(ts.tv_sec)); #else /* Save the LS 32-bits of the system timer in little endian order */ - sched_note_flatten(note->nc_systime, &systime, sizeof(systime)); +#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT + /* Use perf count as tv_nsec to achieve high -precision timestamp */ + + up_perf_convert(count, &ts); Review Comment: need handle overflow -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org