samples: fix kernel_event_logger to work with unified kernel
The test is modified to key on CONFIG_TASK_MONITOR instead of CONFIG_MICROKERNEL, since that is what it was really interested in. Also, this allows the unified kernel to work w.r.t. task monitoring, since that is a concept that is alien to the unified kernel, since there are no more task transitions recorded as part of a kernel server. The unified kernel does not have a CONFIG_TASK_MONITORING option. To make this work, since the kernel_event_logger sample makes use of the philosophers demo, the latter had to be modified as well. The nanokernel philosophers demo would not work with the unifed kernel since it identifies as a microkernel, and in that case the test would be looking for symbols defined in an MDEF file, which the nanokernel demo does not provide of course; the same thing applies to the nanokernel kernel_event_logger sample. Instead, the demo defines NANO_APIS_ONLY=1, which is really what it is interested in. To allow that definition to exist, the nanokernel philosophers demo and both the nano/micro kernel_event_logger samples add src/ directory with its own Makefile and add their own phil_fiber.c and phil.h files, which simply include the original files from the microkernel philosophers demo. As a final change, the kernel_event_logger samples need a different prj.conf file for the unified kernel, since it needs a bigger idle stack than the default, since the kernel event logger does work in the idle thread when the kernel goes to sleep. Change-Id: I4cac45a32d09d6ca1de052a368b3219f64889869 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
673cd8bc2b
commit
c2aecb26cc
|
@ -1,6 +1,6 @@
|
|||
MDEF_FILE = prj.mdef
|
||||
KERNEL_TYPE = micro
|
||||
BOARD ?= qemu_x86
|
||||
CONF_FILE = prj.conf
|
||||
CONF_FILE = prj_${KERNEL_TYPE}.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
||||
|
|
10
samples/kernel_event_logger/microkernel/prj_unified.conf
Normal file
10
samples/kernel_event_logger/microkernel/prj_unified.conf
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Let stack canaries use non-random number generator.
|
||||
# This option is NOT to be used in production code.
|
||||
CONFIG_RING_BUFFER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_SLEEP=y
|
||||
CONFIG_IDLE_STACK_SIZE=512
|
|
@ -1,3 +1 @@
|
|||
ccflags-y += -I${ZEPHYR_BASE}/samples/philosophers/microkernel/src
|
||||
|
||||
obj-y = kernel_event_collector_sample.o ../../../philosophers/microkernel/src/phil_fiber.o
|
||||
obj-y = kernel_event_collector_sample.o phil_fiber.o
|
||||
|
|
|
@ -22,15 +22,15 @@
|
|||
#include <misc/kernel_event_logger.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
#define TAKE(x) nano_fiber_sem_take(&x, TICKS_UNLIMITED)
|
||||
#define GIVE(x) nano_fiber_sem_give(&x)
|
||||
#define SLEEP(x) fiber_sleep(x)
|
||||
#else /* ! CONFIG_NANOKERNEL */
|
||||
#else
|
||||
#define TAKE(x) task_mutex_lock(x, TICKS_UNLIMITED)
|
||||
#define GIVE(x) task_mutex_unlock(x)
|
||||
#define SLEEP(x) task_sleep(x)
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
#endif
|
||||
|
||||
#define RANDDELAY(x) myDelay(((sys_tick_get_32() * ((x) + 1)) & 0x2f) + 1)
|
||||
|
||||
|
@ -68,7 +68,7 @@ struct sleep_data_t sleep_event_data;
|
|||
int is_busy_task_awake;
|
||||
int forks_available = 1;
|
||||
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
#ifdef CONFIG_TASK_MONITOR
|
||||
struct tmon_data_t {
|
||||
uint32_t event_type;
|
||||
uint32_t timestamp;
|
||||
|
@ -132,7 +132,7 @@ void print_context_data(uint32_t thread_id, uint32_t count,
|
|||
PRINTF("\x1b[%d;12H%u ", 16 + indice, count);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
#ifdef CONFIG_TASK_MONITOR
|
||||
void register_tmon_data(uint32_t event_type, uint32_t timestamp,
|
||||
uint32_t task_id, uint32_t data)
|
||||
{
|
||||
|
@ -175,12 +175,12 @@ void print_tmon_status_data(int index)
|
|||
void fork_manager_entry(void)
|
||||
{
|
||||
int i;
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
/* externs */
|
||||
extern struct nano_sem forks[N_PHILOSOPHERS];
|
||||
#else /* ! CONFIG_NANOKERNEL */
|
||||
#else
|
||||
kmutex_t forks[] = {forkMutex0, forkMutex1, forkMutex2, forkMutex3, forkMutex4, forkMutex5};
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
#endif
|
||||
|
||||
SLEEP(2000);
|
||||
while (1) {
|
||||
|
@ -254,7 +254,7 @@ void summary_data_printer(void)
|
|||
PRINTF("\x1b[2;32HForks : all taken ");
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NANOKERNEL
|
||||
#ifndef NANO_APIS_ONLY
|
||||
/* Due to fiber are not pre-emptive, the busy_task_entry thread won't
|
||||
* run as a fiber in nanokernel-only system, because it would affect
|
||||
* the visualization of the sample and the collection of the data
|
||||
|
@ -319,7 +319,7 @@ void summary_data_printer(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
#ifdef CONFIG_TASK_MONITOR
|
||||
/* Print task monitor status data */
|
||||
PRINTF("\x1b[1;64HTASK MONITOR STATUS DATA");
|
||||
PRINTF("\x1b[2;64H-------------------------");
|
||||
|
@ -404,7 +404,7 @@ void profiling_data_collector(void)
|
|||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
#ifdef CONFIG_TASK_MONITOR
|
||||
case KERNEL_EVENT_LOGGER_TASK_MON_TASK_STATE_CHANGE_EVENT_ID:
|
||||
case KERNEL_EVENT_LOGGER_TASK_MON_CMD_PACKET_EVENT_ID:
|
||||
if (data_length != 3) {
|
||||
|
@ -457,7 +457,7 @@ void kernel_event_logger_fiber_start(void)
|
|||
(nano_fiber_entry_t) summary_data_printer, 0, 0, 6, 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
char __stack philStack[N_PHILOSOPHERS+1][STSIZE];
|
||||
struct nano_sem forks[N_PHILOSOPHERS];
|
||||
|
||||
|
@ -472,7 +472,7 @@ int main(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
#ifdef CONFIG_TASK_MONITOR
|
||||
tmon_index = 0;
|
||||
#endif
|
||||
kernel_event_logger_fiber_start();
|
||||
|
|
1
samples/kernel_event_logger/microkernel/src/phil.h
Normal file
1
samples/kernel_event_logger/microkernel/src/phil.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../../philosophers/microkernel/src/phil.h"
|
1
samples/kernel_event_logger/microkernel/src/phil_fiber.c
Normal file
1
samples/kernel_event_logger/microkernel/src/phil_fiber.c
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../../philosophers/microkernel/src/phil_fiber.c"
|
|
@ -1,6 +1,5 @@
|
|||
KERNEL_TYPE = nano
|
||||
BOARD ?= qemu_x86
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/kernel_event_logger/microkernel/src/
|
||||
CONF_FILE = prj.conf
|
||||
CONF_FILE = prj_${KERNEL_TYPE}.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
||||
|
|
10
samples/kernel_event_logger/nanokernel/prj_unified.conf
Normal file
10
samples/kernel_event_logger/nanokernel/prj_unified.conf
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Let stack canaries use non-random number generator.
|
||||
# This option is NOT to be used in production code.
|
||||
CONFIG_RING_BUFFER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_SLEEP=y
|
||||
CONFIG_IDLE_STACK_SIZE=512
|
3
samples/kernel_event_logger/nanokernel/src/Makefile
Normal file
3
samples/kernel_event_logger/nanokernel/src/Makefile
Normal file
|
@ -0,0 +1,3 @@
|
|||
ccflags-y += -DNANO_APIS_ONLY=1
|
||||
|
||||
obj-y = kernel_event_collector_sample.o phil_fiber.o
|
|
@ -0,0 +1 @@
|
|||
#include "../../microkernel/src/kernel_event_collector_sample.c"
|
1
samples/kernel_event_logger/nanokernel/src/phil.h
Normal file
1
samples/kernel_event_logger/nanokernel/src/phil.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../../philosophers/microkernel/src/phil.h"
|
1
samples/kernel_event_logger/nanokernel/src/phil_fiber.c
Normal file
1
samples/kernel_event_logger/nanokernel/src/phil_fiber.c
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../../philosophers/microkernel/src/phil_fiber.c"
|
|
@ -18,28 +18,28 @@
|
|||
#include <zephyr.h>
|
||||
#include "phil.h"
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
#define FORK(x) (&forks[x])
|
||||
#define TAKE(x) nano_fiber_sem_take(x, TICKS_UNLIMITED)
|
||||
#define GIVE(x) nano_fiber_sem_give(x)
|
||||
#else /* ! CONFIG_NANOKERNEL */
|
||||
#else
|
||||
#define FORK(x) forks[x]
|
||||
#define TAKE(x) task_mutex_lock(x, TICKS_UNLIMITED)
|
||||
#define GIVE(x) task_mutex_unlock(x)
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
#endif
|
||||
|
||||
#define RANDDELAY(x) myDelay(((sys_tick_get_32() * ((x) + 1)) & 0x1f) + 1)
|
||||
|
||||
#define PRINT(x, y) myPrint(x, y)
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
/* externs */
|
||||
|
||||
extern struct nano_sem forks[N_PHILOSOPHERS];
|
||||
#else /* ! CONFIG_NANOKERNEL */
|
||||
#else
|
||||
kmutex_t forks[] = {forkMutex0, forkMutex1, forkMutex2, forkMutex3, forkMutex4,
|
||||
forkMutex5};
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -67,14 +67,14 @@ static void myPrint(int id, char *str)
|
|||
|
||||
static void myDelay(int ticks)
|
||||
{
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
task_sleep(ticks);
|
||||
#else
|
||||
#ifdef NANO_APIS_ONLY
|
||||
struct nano_timer timer;
|
||||
|
||||
nano_timer_init(&timer, (void *) 0);
|
||||
nano_fiber_timer_start(&timer, ticks);
|
||||
nano_fiber_timer_test(&timer, TICKS_UNLIMITED);
|
||||
#else
|
||||
task_sleep(ticks);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ static void myDelay(int ticks)
|
|||
|
||||
void philEntry(void)
|
||||
{
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
struct nano_sem *f1; /* fork #1 */
|
||||
struct nano_sem *f2; /* fork #2 */
|
||||
#else
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"implementation demonstrates the usage of multiple (6) %s\n" \
|
||||
"of differing priorities and the %s semaphores and timers."
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
#define STSIZE 1024
|
||||
|
||||
/* externs */
|
||||
|
@ -37,9 +37,9 @@ extern void philEntry(void);
|
|||
|
||||
char __stack philStack[N_PHILOSOPHERS][STSIZE];
|
||||
struct nano_sem forks[N_PHILOSOPHERS];
|
||||
#endif /* CONFIG_NANOKERNEL */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NANOKERNEL
|
||||
#ifdef NANO_APIS_ONLY
|
||||
/**
|
||||
*
|
||||
* @brief Nanokernel entry point
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
KERNEL_TYPE = nano
|
||||
BOARD ?= qemu_x86
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/philosophers/microkernel/src/
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
||||
|
|
4
samples/philosophers/nanokernel/src/Makefile
Normal file
4
samples/philosophers/nanokernel/src/Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
ccflags-y += -I${ZEPHYR_BASE}/samples/philosophers/microkernel/src
|
||||
ccflags-y += -DNANO_APIS_ONLY=1
|
||||
|
||||
obj-y = ../../microkernel/src/phil_fiber.o ../../microkernel/src/phil_task.o
|
Loading…
Reference in a new issue