2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2021-11-12 11:04:23 +01:00
|
|
|
* apps/system/sched_note/note_main.c
|
2016-03-17 23:02:28 +01:00
|
|
|
*
|
2020-06-16 20:30:41 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2016-03-17 23:02:28 +01:00
|
|
|
*
|
2020-06-16 20:30:41 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-03-17 23:02:28 +01:00
|
|
|
*
|
2020-06-16 20:30:41 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-03-17 23:02:28 +01:00
|
|
|
*
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2016-03-17 23:02:28 +01:00
|
|
|
* Included Files
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
2020-06-16 20:30:41 +02:00
|
|
|
#include <inttypes.h>
|
2016-03-17 23:02:28 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <nuttx/sched_note.h>
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
/************************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES
|
|
|
|
# define syslog_time(priority, fmt, ...) \
|
|
|
|
syslog(priority, "%08lx.%08lx: " fmt, \
|
|
|
|
(unsigned long)systime_sec, (unsigned long)systime_nsec, \
|
|
|
|
__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
# define syslog_time(priority, fmt, ...) \
|
|
|
|
syslog(priority, "%08lx: " fmt, \
|
|
|
|
(unsigned long)systime, \
|
|
|
|
__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2016-03-17 23:02:28 +01:00
|
|
|
* Private Data
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
static bool g_note_daemon_started;
|
2016-05-19 03:22:47 +02:00
|
|
|
static uint8_t g_note_buffer[CONFIG_SYSTEM_NOTE_BUFFERSIZE];
|
2016-03-17 23:02:28 +01:00
|
|
|
|
2016-03-21 22:25:11 +01:00
|
|
|
/* Names of task/thread states */
|
|
|
|
|
|
|
|
static FAR const char *g_statenames[] =
|
|
|
|
{
|
|
|
|
"Invalid",
|
|
|
|
"Waiting for Unlock",
|
|
|
|
"Ready",
|
|
|
|
"Running",
|
|
|
|
"Inactive",
|
|
|
|
"Waiting for Semaphore",
|
|
|
|
"Waiting for Signal",
|
|
|
|
#ifndef CONFIG_DISABLE_MQUEUE
|
|
|
|
"Waiting for MQ empty",
|
|
|
|
"Waiting for MQ full"
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NSTATES (sizeof(g_statenames)/sizeof(FAR const char *))
|
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2016-03-17 23:02:28 +01:00
|
|
|
* Private Functions
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2016-03-17 23:02:28 +01:00
|
|
|
* Name: dump_notes
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
static void dump_notes(size_t nread)
|
|
|
|
{
|
|
|
|
FAR struct note_common_s *note;
|
2020-10-05 07:54:25 +02:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES
|
|
|
|
uint32_t systime_sec;
|
|
|
|
uint32_t systime_nsec;
|
|
|
|
#else
|
2016-03-17 23:02:28 +01:00
|
|
|
uint32_t systime;
|
2020-10-05 07:54:25 +02:00
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
pid_t pid;
|
|
|
|
off_t offset;
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
while (offset < nread)
|
|
|
|
{
|
|
|
|
note = (FAR struct note_common_s *)&g_note_buffer[offset];
|
2016-03-21 21:09:25 +01:00
|
|
|
pid = (pid_t)note->nc_pid[0] +
|
|
|
|
((pid_t)note->nc_pid[1] << 8);
|
2020-10-05 07:54:25 +02:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES
|
|
|
|
systime_nsec = (uint32_t)note->nc_systime_nsec[0] +
|
|
|
|
(uint32_t)(note->nc_systime_nsec[1] << 8) +
|
|
|
|
(uint32_t)(note->nc_systime_nsec[2] << 16) +
|
|
|
|
(uint32_t)(note->nc_systime_nsec[3] << 24);
|
|
|
|
systime_sec = (uint32_t)note->nc_systime_sec[0] +
|
|
|
|
(uint32_t)(note->nc_systime_sec[1] << 8) +
|
|
|
|
(uint32_t)(note->nc_systime_sec[2] << 16) +
|
|
|
|
(uint32_t)(note->nc_systime_sec[3] << 24);
|
|
|
|
#else
|
2016-03-17 23:02:28 +01:00
|
|
|
systime = (uint32_t) note->nc_systime[0] +
|
|
|
|
(uint32_t)(note->nc_systime[1] << 8) +
|
2016-03-17 23:13:43 +01:00
|
|
|
(uint32_t)(note->nc_systime[2] << 16) +
|
|
|
|
(uint32_t)(note->nc_systime[3] << 24);
|
2020-10-05 07:54:25 +02:00
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
switch (note->nc_type)
|
|
|
|
{
|
|
|
|
case NOTE_START:
|
|
|
|
{
|
|
|
|
FAR struct note_start_s *note_start =
|
|
|
|
(FAR struct note_start_s *)note;
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
if (note->nc_length < sizeof(struct note_start_s))
|
2016-03-17 23:02:28 +01:00
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Note too small for \"Start\" note: %d\n",
|
2016-03-21 21:09:25 +01:00
|
|
|
note->nc_length);
|
2016-03-17 23:02:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#if CONFIG_TASK_NAME_SIZE > 0
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u \"%s\" started, CPU%u, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
note_start->nst_name, (unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u started, CPU%u, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
#endif
|
|
|
|
#else
|
2016-03-17 23:02:28 +01:00
|
|
|
#if CONFIG_TASK_NAME_SIZE > 0
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u \"%s\" started, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
note_start->nst_name, (unsigned int)note->nc_priority);
|
2016-03-17 23:02:28 +01:00
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u started, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_STOP:
|
|
|
|
{
|
2016-03-21 21:09:25 +01:00
|
|
|
if (note->nc_length != sizeof(struct note_stop_s))
|
2016-03-17 23:02:28 +01:00
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"Stop\" note: %d\n",
|
2016-03-21 21:09:25 +01:00
|
|
|
note->nc_length);
|
2016-03-17 23:02:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u stopped, CPU%u, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_cpu, (unsigned int)note->nc_priority);
|
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u stopped, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-12-03 05:46:18 +01:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
|
2016-03-21 21:09:25 +01:00
|
|
|
case NOTE_SUSPEND:
|
2016-03-17 23:02:28 +01:00
|
|
|
{
|
2016-03-21 22:25:11 +01:00
|
|
|
FAR struct note_suspend_s *note_suspend =
|
|
|
|
(FAR struct note_suspend_s *)note;
|
|
|
|
FAR const char *statename;
|
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_suspend_s))
|
2016-03-17 23:02:28 +01:00
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"Suspend\" note: %d\n",
|
2016-03-21 21:09:25 +01:00
|
|
|
note->nc_length);
|
2016-03-17 23:02:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-21 22:25:11 +01:00
|
|
|
if (note_suspend->nsu_state < NSTATES)
|
2016-03-21 21:09:25 +01:00
|
|
|
{
|
2016-03-21 22:25:11 +01:00
|
|
|
statename = g_statenames[note_suspend->nsu_state];
|
2016-03-21 21:09:25 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-21 22:25:11 +01:00
|
|
|
statename = "ERROR";
|
|
|
|
}
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u suspended, CPU%u, priority %u, state \"%s\"\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 22:25:11 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority, statename);
|
2016-03-21 21:09:25 +01:00
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u suspended, priority %u, state \"%s\"\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 22:25:11 +01:00
|
|
|
(unsigned int)note->nc_priority, statename);
|
2016-03-21 21:09:25 +01:00
|
|
|
#endif
|
2016-03-21 22:25:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_RESUME:
|
|
|
|
{
|
|
|
|
if (note->nc_length != sizeof(struct note_resume_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"Resume\" note: %d\n",
|
2016-03-21 22:25:11 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
2016-03-21 21:09:25 +01:00
|
|
|
}
|
2016-03-21 22:25:11 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u resumed, CPU%u, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 22:25:11 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u resumed, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 22:25:11 +01:00
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-12-03 05:46:18 +01:00
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
|
2016-11-28 00:13:26 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2016-12-07 16:08:55 +01:00
|
|
|
case NOTE_CPU_START:
|
|
|
|
{
|
|
|
|
FAR struct note_cpu_start_s *note_start =
|
|
|
|
(FAR struct note_cpu_start_s *)note;
|
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_cpu_start_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"CPU Start\" note: %d\n",
|
2016-12-07 16:08:55 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u requests CPU%u to start, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-12-07 16:08:55 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note_start->ncs_target,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_CPU_STARTED:
|
|
|
|
{
|
|
|
|
if (note->nc_length != sizeof(struct note_cpu_started_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"CPU started\" note: %d\n",
|
2016-12-07 16:08:55 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u has started, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-12-07 16:08:55 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-12-03 05:46:18 +01:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
|
2016-11-28 00:13:26 +01:00
|
|
|
case NOTE_CPU_PAUSE:
|
|
|
|
{
|
|
|
|
FAR struct note_cpu_pause_s *note_pause =
|
|
|
|
(FAR struct note_cpu_pause_s *)note;
|
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_cpu_pause_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"CPU pause\" note: %d\n",
|
2016-11-28 00:13:26 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u requests CPU%u to pause, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-11-28 00:13:26 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note_pause->ncp_target,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_CPU_PAUSED:
|
|
|
|
{
|
|
|
|
if (note->nc_length != sizeof(struct note_cpu_paused_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"CPU paused\" note: %d\n",
|
2016-11-28 00:13:26 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u has paused, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-11-28 00:13:26 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_CPU_RESUME:
|
|
|
|
{
|
|
|
|
FAR struct note_cpu_resume_s *note_resume =
|
|
|
|
(FAR struct note_cpu_resume_s *)note;
|
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_cpu_resume_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"CPU resume\" note: %d\n",
|
2016-11-28 00:13:26 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u requests CPU%u to resume, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-11-28 00:13:26 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note_resume->ncr_target,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_CPU_RESUMED:
|
|
|
|
{
|
|
|
|
if (note->nc_length != sizeof(struct note_cpu_resumed_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"CPU resumed\" note: %d\n",
|
2016-11-28 00:13:26 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u has resumed, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-11-28 00:13:26 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2021-12-03 05:46:18 +01:00
|
|
|
#endif
|
2016-11-28 00:13:26 +01:00
|
|
|
|
2016-03-17 23:02:28 +01:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
|
|
|
|
case NOTE_PREEMPT_LOCK:
|
|
|
|
case NOTE_PREEMPT_UNLOCK:
|
|
|
|
{
|
|
|
|
FAR struct note_preempt_s *note_preempt =
|
|
|
|
(FAR struct note_preempt_s *)note;
|
|
|
|
uint16_t count;
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
if (note->nc_length != sizeof(struct note_preempt_s))
|
2016-03-17 23:02:28 +01:00
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"Preemption\" note: %d\n",
|
2016-03-21 21:09:25 +01:00
|
|
|
note->nc_length);
|
2016-03-17 23:02:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = (uint16_t) note_preempt->npr_count[0] +
|
|
|
|
(uint16_t)(note_preempt->npr_count[1] << 8);
|
|
|
|
|
|
|
|
if (note->nc_type == NOTE_PREEMPT_LOCK)
|
|
|
|
{
|
2016-03-21 21:09:25 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u locked, CPU%u, priority %u, count=%u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority, (unsigned int)count);
|
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u locked, priority %u, count=%u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_priority, (unsigned int)count);
|
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-21 21:09:25 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u unlocked, CPU%u, priority %u, count=%u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority, (unsigned int)count);
|
|
|
|
#else
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u unlocked, priority %u, count=%u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_priority, (unsigned int)count);
|
|
|
|
#endif
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
#endif
|
2016-12-01 19:39:51 +01:00
|
|
|
|
2016-03-17 23:02:28 +01:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
|
|
|
|
case NOTE_CSECTION_ENTER:
|
|
|
|
case NOTE_CSECTION_LEAVE:
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
2016-12-01 19:39:51 +01:00
|
|
|
FAR struct note_csection_s *note_csection =
|
|
|
|
(FAR struct note_csection_s *)note;
|
2016-03-17 23:02:28 +01:00
|
|
|
uint16_t count;
|
|
|
|
#endif
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
if (note->nc_length != sizeof(struct note_csection_s))
|
2016-03-17 23:02:28 +01:00
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"csection\" note: %d\n",
|
2016-03-21 21:09:25 +01:00
|
|
|
note->nc_length);
|
2016-03-17 23:02:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
count = (uint16_t) note_csection->ncs_count[0] +
|
|
|
|
(uint16_t)(note_csection->ncs_count[1] << 8);
|
|
|
|
|
|
|
|
if (note->nc_type == NOTE_CSECTION_ENTER)
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u enter csection, CPU%u, priority %u, "
|
2020-06-16 20:30:41 +02:00
|
|
|
"count=%u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority, (unsigned int)count);
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u leave csection, CPU%u, priority %u, "
|
2020-06-16 20:30:41 +02:00
|
|
|
"count=%u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
|
|
|
(unsigned int)note->nc_priority, (unsigned int)count);
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (note->nc_type == NOTE_CSECTION_ENTER)
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO, "Task %u enter csection, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_priority);
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO, "Task %u leave csection, priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2016-03-21 21:09:25 +01:00
|
|
|
(unsigned int)note->nc_priority);
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2016-12-01 19:39:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
|
|
|
|
case NOTE_SPINLOCK_LOCK:
|
|
|
|
case NOTE_SPINLOCK_LOCKED:
|
|
|
|
case NOTE_SPINLOCK_UNLOCK:
|
|
|
|
case NOTE_SPINLOCK_ABORT:
|
|
|
|
{
|
|
|
|
FAR struct note_spinlock_s *note_spinlock =
|
|
|
|
(FAR struct note_spinlock_s *)note;
|
2020-10-16 16:08:48 +02:00
|
|
|
FAR void *spinlock;
|
2016-12-01 19:39:51 +01:00
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_spinlock_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"Spinlock\" note: %d\n",
|
2016-12-01 19:39:51 +01:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
2016-03-17 23:02:28 +01:00
|
|
|
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock = (FAR void *)
|
|
|
|
((uintptr_t)note_spinlock->nsp_spinlock[0]
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[1] << 8)
|
|
|
|
#if UINTPTR_MAX > UINT16_MAX
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[2] << 16)
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[3] << 24)
|
|
|
|
#if UINTPTR_MAX > UINT32_MAX
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[4] << 32)
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[5] << 40)
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[6] << 48)
|
|
|
|
+ ((uintptr_t)note_spinlock->nsp_spinlock[7] << 56)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2016-12-01 19:39:51 +01:00
|
|
|
switch (note->nc_type)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
case NOTE_SPINLOCK_LOCK:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u wait for spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SPINLOCK_LOCKED:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u has spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SPINLOCK_UNLOCK:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u unlocking spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SPINLOCK_ABORT:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u CPU%u abort wait on spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note->nc_cpu,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#else
|
|
|
|
case NOTE_SPINLOCK_LOCK:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u wait for spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SPINLOCK_LOCKED:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u has spinlock=%p value=%u priority %u\n",
|
|
|
|
(unsigned int)pid,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SPINLOCK_UNLOCK:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u unlocking spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SPINLOCK_ABORT:
|
|
|
|
{
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u abort wait on spinlock=%p value=%u "
|
2020-06-16 20:30:41 +02:00
|
|
|
"priority %u\n",
|
2020-10-05 07:54:25 +02:00
|
|
|
(unsigned int)pid,
|
2020-10-16 16:08:48 +02:00
|
|
|
spinlock,
|
2016-12-01 19:39:51 +01:00
|
|
|
(unsigned int)note_spinlock->nsp_value,
|
|
|
|
(unsigned int)note->nc_priority);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
2020-10-16 16:08:48 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-03-17 23:02:28 +01:00
|
|
|
#endif
|
2016-12-01 19:39:51 +01:00
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
|
|
|
case NOTE_SYSCALL_ENTER:
|
|
|
|
{
|
|
|
|
FAR struct note_syscall_enter_s *note_sysenter =
|
|
|
|
(FAR struct note_syscall_enter_s *)note;
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
if (note->nc_length < SIZEOF_NOTE_SYSCALL_ENTER(0))
|
2020-06-16 20:30:41 +02:00
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"SYSCALL enter\" note: %d\n",
|
2020-06-16 20:30:41 +02:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u Enter SYSCALL %d\n",
|
|
|
|
(unsigned int)pid,
|
2020-06-16 20:30:41 +02:00
|
|
|
note_sysenter->nsc_nr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SYSCALL_LEAVE:
|
|
|
|
{
|
|
|
|
FAR struct note_syscall_leave_s *note_sysleave =
|
|
|
|
(FAR struct note_syscall_leave_s *)note;
|
2020-10-16 16:08:48 +02:00
|
|
|
uintptr_t result;
|
2020-06-16 20:30:41 +02:00
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_syscall_leave_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"SYSCALL leave\" note: %d\n",
|
2020-06-16 20:30:41 +02:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-16 16:08:48 +02:00
|
|
|
result = (uintptr_t)note_sysleave->nsc_result[0]
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[1] << 8)
|
|
|
|
#if UINTPTR_MAX > UINT16_MAX
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[2] << 16)
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[3] << 24)
|
|
|
|
#if UINTPTR_MAX > UINT32_MAX
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[4] << 32)
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[5] << 40)
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[6] << 48)
|
|
|
|
+ ((uintptr_t)note_sysleave->nsc_result[7] << 56)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u Leave SYSCALL %d: %" PRIdPTR "\n",
|
|
|
|
(unsigned int)pid,
|
2020-10-16 16:08:48 +02:00
|
|
|
note_sysleave->nsc_nr, result);
|
2020-06-16 20:30:41 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
|
|
|
|
case NOTE_IRQ_ENTER:
|
|
|
|
case NOTE_IRQ_LEAVE:
|
|
|
|
{
|
|
|
|
FAR struct note_irqhandler_s *note_irq =
|
|
|
|
(FAR struct note_irqhandler_s *)note;
|
|
|
|
|
|
|
|
if (note->nc_length != sizeof(struct note_irqhandler_s))
|
|
|
|
{
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR,
|
2021-11-11 15:23:46 +01:00
|
|
|
"Size incorrect for \"IRQ\" note: %d\n",
|
2020-06-16 20:30:41 +02:00
|
|
|
note->nc_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-05 07:54:25 +02:00
|
|
|
syslog_time(LOG_INFO,
|
|
|
|
"Task %u %s IRQ %d\n",
|
|
|
|
(unsigned int)pid,
|
2020-06-16 20:30:41 +02:00
|
|
|
note->nc_type == NOTE_IRQ_ENTER ? "Enter" : "Leave",
|
|
|
|
note_irq->nih_irq);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2016-03-17 23:02:28 +01:00
|
|
|
default:
|
|
|
|
syslog(LOG_INFO, "Unrecognized note type: %d\n", note->nc_type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-21 21:09:25 +01:00
|
|
|
offset += note->nc_length;
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2016-03-17 23:02:28 +01:00
|
|
|
* Name: note_daemon
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
static int note_daemon(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
ssize_t nread;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
/* Indicate that we are running */
|
|
|
|
|
|
|
|
g_note_daemon_started = true;
|
|
|
|
syslog(LOG_INFO, "note_daemon: Running\n");
|
|
|
|
|
|
|
|
/* Open the note driver */
|
|
|
|
|
|
|
|
syslog(LOG_INFO, "note_daemon: Opening /dev/note\n");
|
|
|
|
fd = open("/dev/note", O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
int errcode = errno;
|
2021-11-11 15:16:24 +01:00
|
|
|
syslog(LOG_ERR, "note_daemon: ERROR: Failed to open /dev/note: %d\n",
|
2016-03-17 23:02:28 +01:00
|
|
|
errcode);
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now loop forever, dumping note data to the display */
|
|
|
|
|
|
|
|
for (; ; )
|
|
|
|
{
|
2016-05-19 03:22:47 +02:00
|
|
|
nread = read(fd, g_note_buffer, CONFIG_SYSTEM_NOTE_BUFFERSIZE);
|
2016-03-17 23:02:28 +01:00
|
|
|
if (nread > 0)
|
|
|
|
{
|
|
|
|
dump_notes(nread);
|
|
|
|
}
|
|
|
|
|
2016-05-19 03:22:47 +02:00
|
|
|
usleep(CONFIG_SYSTEM_NOTE_DELAY * 1000L);
|
2016-03-17 23:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
close(fd);
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
errout:
|
|
|
|
g_note_daemon_started = false;
|
|
|
|
|
|
|
|
syslog(LOG_INFO, "note_daemon: Terminating\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
2016-03-17 23:02:28 +01:00
|
|
|
* Public Functions
|
2020-06-16 20:30:41 +02:00
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
2020-06-16 20:30:41 +02:00
|
|
|
/************************************************************************************
|
|
|
|
* Name: note_main
|
|
|
|
************************************************************************************/
|
2016-03-17 23:02:28 +01:00
|
|
|
|
|
|
|
int main(int argc, FAR char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
printf("note_main: Starting the note_daemon\n");
|
|
|
|
if (g_note_daemon_started)
|
|
|
|
{
|
|
|
|
printf("note_main: note_daemon already running\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-05-19 03:22:47 +02:00
|
|
|
ret = task_create("note_daemon", CONFIG_SYSTEM_NOTE_PRIORITY,
|
|
|
|
CONFIG_SYSTEM_NOTE_STACKSIZE, note_daemon,
|
2017-05-09 18:59:24 +02:00
|
|
|
NULL);
|
2016-03-17 23:02:28 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
int errcode = errno;
|
|
|
|
printf("note_main: ERROR: Failed to start note_daemon: %d\n",
|
|
|
|
errcode);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("note_main: note_daemon started\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|