MCPcopy Create free account
hub / github.com/apache/nuttx / note_record_taskname

Function note_record_taskname

drivers/note/note_driver.c:501–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499 ****************************************************************************/
500
501static void note_record_taskname(pid_t pid, FAR const char *name)
502{
503 FAR struct note_taskname_info_s *ti;
504 size_t tilen;
505 size_t namelen;
506 size_t skiplen;
507 size_t remain;
508
509 namelen = strlen(name);
510 DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE);
511 tilen = sizeof(struct note_taskname_info_s) + namelen;
512 DEBUGASSERT(tilen <= UCHAR_MAX);
513
514 skiplen = CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE - g_note_taskname.head;
515 if (skiplen >= tilen + sizeof(struct note_taskname_info_s))
516 {
517 skiplen = 0; /* Have enough space at the tail - needn't skip */
518 }
519
520 if (g_note_taskname.head >= g_note_taskname.tail)
521 {
522 remain = CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE -
523 (g_note_taskname.head - g_note_taskname.tail);
524 }
525 else
526 {
527 remain = g_note_taskname.tail - g_note_taskname.head;
528 }
529
530 while (skiplen + tilen >= remain)
531 {
532 /* No enough space, drop the old info */
533
534 ti = (FAR struct note_taskname_info_s *)
535 &g_note_taskname.buffer[g_note_taskname.tail];
536 g_note_taskname.tail = (g_note_taskname.tail + ti->size) %
537 CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE;
538 remain += ti->size;
539 }
540
541 if (skiplen)
542 {
543 /* Fill the skipped region with an invalid info */
544
545 ti = (FAR struct note_taskname_info_s *)
546 &g_note_taskname.buffer[g_note_taskname.head];
547 ti->size = skiplen;
548 ti->pid = INVALID_PROCESS_ID;
549 ti->name[0] = '\0';
550
551 /* Move to the begin of circle buffer */
552
553 g_note_taskname.head = 0;
554 }
555
556 ti = (FAR struct note_taskname_info_s *)
557 &g_note_taskname.buffer[g_note_taskname.head];
558 ti->size = NOTE_ALIGN(tilen);

Callers 1

sched_note_stopFunction · 0.85

Calls 2

strlenFunction · 0.50
strlcpyFunction · 0.50

Tested by

no test coverage detected