| 638 | ****************************************************************************/ |
| 639 | |
| 640 | void sched_note_start(FAR struct tcb_s *tcb) |
| 641 | { |
| 642 | struct note_startalloc_s note; |
| 643 | unsigned int length; |
| 644 | FAR struct note_driver_s **driver; |
| 645 | bool formatted = false; |
| 646 | |
| 647 | #if CONFIG_TASK_NAME_SIZE > 0 |
| 648 | int namelen = 0; |
| 649 | #endif |
| 650 | |
| 651 | for (driver = g_note_drivers; *driver; driver++) |
| 652 | { |
| 653 | if (!note_isenabled(*driver)) |
| 654 | { |
| 655 | continue; |
| 656 | } |
| 657 | |
| 658 | if (note_start(*driver, tcb)) |
| 659 | { |
| 660 | continue; |
| 661 | } |
| 662 | |
| 663 | if ((*driver)->ops->add == NULL) |
| 664 | { |
| 665 | continue; |
| 666 | } |
| 667 | |
| 668 | if (!formatted) |
| 669 | { |
| 670 | formatted = true; |
| 671 | |
| 672 | /* Copy the task name (if possible) and |
| 673 | * get the length of the note |
| 674 | */ |
| 675 | |
| 676 | #if CONFIG_TASK_NAME_SIZE > 0 |
| 677 | if (tcb->name[0] != '\0') |
| 678 | { |
| 679 | namelen = strlen(tcb->name); |
| 680 | } |
| 681 | |
| 682 | DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); |
| 683 | strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name)); |
| 684 | |
| 685 | length = SIZEOF_NOTE_START(namelen + 1); |
| 686 | #else |
| 687 | length = SIZEOF_NOTE_START(0); |
| 688 | #endif |
| 689 | |
| 690 | /* Finish formatting the note */ |
| 691 | |
| 692 | note_common(tcb, ¬e.nsa_cmn, length, NOTE_START); |
| 693 | } |
| 694 | |
| 695 | /* Add the note to circular buffer */ |
| 696 | |
| 697 | note_add(*driver, ¬e, length); |
no test coverage detected