| 1053 | |
| 1054 | #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION |
| 1055 | void sched_note_preemption(FAR struct tcb_s *tcb, bool locked) |
| 1056 | { |
| 1057 | struct note_preempt_s note; |
| 1058 | FAR struct note_driver_s **driver; |
| 1059 | bool formatted = false; |
| 1060 | irqstate_t flags; |
| 1061 | |
| 1062 | flags = spin_lock_irqsave_notrace(&g_note_lock); |
| 1063 | for (driver = g_note_drivers; *driver; driver++) |
| 1064 | { |
| 1065 | if (!note_isenabled(*driver)) |
| 1066 | { |
| 1067 | continue; |
| 1068 | } |
| 1069 | |
| 1070 | if (note_preemption(*driver, tcb, locked)) |
| 1071 | { |
| 1072 | continue; |
| 1073 | } |
| 1074 | |
| 1075 | if ((*driver)->ops->add == NULL) |
| 1076 | { |
| 1077 | continue; |
| 1078 | } |
| 1079 | |
| 1080 | /* Format the note */ |
| 1081 | |
| 1082 | if (!formatted) |
| 1083 | { |
| 1084 | formatted = true; |
| 1085 | note_common(tcb, ¬e.npr_cmn, sizeof(struct note_preempt_s), |
| 1086 | locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK); |
| 1087 | note.npr_count = tcb->lockcount; |
| 1088 | } |
| 1089 | |
| 1090 | /* Add the note to circular buffer */ |
| 1091 | |
| 1092 | note_add(*driver, ¬e, sizeof(struct note_preempt_s)); |
| 1093 | } |
| 1094 | |
| 1095 | spin_unlock_irqrestore_notrace(&g_note_lock, flags); |
| 1096 | } |
| 1097 | #endif |
| 1098 | |
| 1099 | #ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION |
no test coverage detected