samples: rename hello_world -> synchronisation
This sample is more than just a hello world, it demonstrates basic kernel functionality that deserve to be its own sample. A simplified Hello World sample will replace this one. Change-Id: I9120daa1923f99def994e484783abe04db5b14eb Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
ab38b9ce8e
commit
ba860ba8e9
17 changed files with 84 additions and 60 deletions
|
@ -1,6 +1,6 @@
|
|||
KERNEL_TYPE = nano
|
||||
BOARD ?= quark_se
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/hello_world/src/
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/nanokernel/apps/synchronization/src/
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
KERNEL_TYPE = nano
|
||||
BOARD ?= quark_se_ss
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/hello_world/src/
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/nanokernel/apps/synchronization/src/
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
|
@ -1 +0,0 @@
|
|||
obj-y = hello.o
|
|
@ -1,6 +1,6 @@
|
|||
MDEF_FILE = prj.mdef
|
||||
KERNEL_TYPE = micro
|
||||
BOARD ?= qemu_x86
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
|
@ -1,4 +1,4 @@
|
|||
Title: Hello World
|
||||
Title: Synchronisation
|
||||
|
||||
Description:
|
||||
|
1
samples/microkernel/apps/synchronization/src/Makefile
Normal file
1
samples/microkernel/apps/synchronization/src/Makefile
Normal file
|
@ -0,0 +1 @@
|
|||
obj-y = main.o
|
76
samples/microkernel/apps/synchronization/src/main.c
Normal file
76
samples/microkernel/apps/synchronization/src/main.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* hello.c - Hello World demo */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Wind River Systems, Inc.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
|
||||
#if defined(CONFIG_STDOUT_CONSOLE)
|
||||
#include <stdio.h>
|
||||
#define PRINT printf
|
||||
#else
|
||||
#include <misc/printk.h>
|
||||
#define PRINT printk
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Microkernel version of hello world demo has two tasks that utilize
|
||||
* semaphores and sleeps to take turns printing a greeting message at
|
||||
* a controlled rate.
|
||||
*/
|
||||
|
||||
|
||||
/* specify delay between greetings (in ms); compute equivalent in ticks */
|
||||
|
||||
#define SLEEPTIME 500
|
||||
#define SLEEPTICKS (SLEEPTIME * sys_clock_ticks_per_sec / 1000)
|
||||
|
||||
/*
|
||||
*
|
||||
* @param taskname task identification string
|
||||
* @param mySem task's own semaphore
|
||||
* @param otherSem other task's semaphore
|
||||
*
|
||||
*/
|
||||
void helloLoop(const char *taskname, ksem_t mySem, ksem_t otherSem)
|
||||
{
|
||||
while (1) {
|
||||
task_sem_take(mySem, TICKS_UNLIMITED);
|
||||
|
||||
/* say "hello" */
|
||||
PRINT("%s: Hello World!\n", taskname);
|
||||
|
||||
/* wait a while, then let other task have a turn */
|
||||
task_sleep(SLEEPTICKS);
|
||||
task_sem_give(otherSem);
|
||||
}
|
||||
}
|
||||
|
||||
void taskA(void)
|
||||
{
|
||||
/* taskA gives its own semaphore, allowing it to say hello right away */
|
||||
task_sem_give(TASKASEM);
|
||||
|
||||
/* invoke routine that allows task to ping-pong hello messages with taskB */
|
||||
helloLoop(__func__, TASKASEM, TASKBSEM);
|
||||
}
|
||||
|
||||
void taskB(void)
|
||||
{
|
||||
/* invoke routine that allows task to ping-pong hello messages with taskA */
|
||||
helloLoop(__func__, TASKBSEM, TASKASEM);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
KERNEL_TYPE = nano
|
||||
BOARD ?= qemu_x86
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/hello_world/src/
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/nanokernel/apps/synchronization/src/
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
Title: Hello World
|
||||
Title: Synchronisation
|
||||
|
||||
Description:
|
||||
|
1
samples/nanokernel/apps/synchronization/src/Makefile
Normal file
1
samples/nanokernel/apps/synchronization/src/Makefile
Normal file
|
@ -0,0 +1 @@
|
|||
obj-y += main.o
|
|
@ -26,57 +26,6 @@
|
|||
#define PRINT printk
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MICROKERNEL
|
||||
|
||||
/*
|
||||
* Microkernel version of hello world demo has two tasks that utilize
|
||||
* semaphores and sleeps to take turns printing a greeting message at
|
||||
* a controlled rate.
|
||||
*/
|
||||
|
||||
|
||||
/* specify delay between greetings (in ms); compute equivalent in ticks */
|
||||
|
||||
#define SLEEPTIME 500
|
||||
#define SLEEPTICKS (SLEEPTIME * sys_clock_ticks_per_sec / 1000)
|
||||
|
||||
/*
|
||||
*
|
||||
* @param taskname task identification string
|
||||
* @param mySem task's own semaphore
|
||||
* @param otherSem other task's semaphore
|
||||
*
|
||||
*/
|
||||
void helloLoop(const char *taskname, ksem_t mySem, ksem_t otherSem)
|
||||
{
|
||||
while (1) {
|
||||
task_sem_take(mySem, TICKS_UNLIMITED);
|
||||
|
||||
/* say "hello" */
|
||||
PRINT("%s: Hello World!\n", taskname);
|
||||
|
||||
/* wait a while, then let other task have a turn */
|
||||
task_sleep(SLEEPTICKS);
|
||||
task_sem_give(otherSem);
|
||||
}
|
||||
}
|
||||
|
||||
void taskA(void)
|
||||
{
|
||||
/* taskA gives its own semaphore, allowing it to say hello right away */
|
||||
task_sem_give(TASKASEM);
|
||||
|
||||
/* invoke routine that allows task to ping-pong hello messages with taskB */
|
||||
helloLoop(__func__, TASKASEM, TASKBSEM);
|
||||
}
|
||||
|
||||
void taskB(void)
|
||||
{
|
||||
/* invoke routine that allows task to ping-pong hello messages with taskA */
|
||||
helloLoop(__func__, TASKBSEM, TASKASEM);
|
||||
}
|
||||
|
||||
#else /* CONFIG_NANOKERNEL */
|
||||
|
||||
/*
|
||||
* Nanokernel version of hello world demo has a task and a fiber that utilize
|
||||
|
@ -144,4 +93,3 @@ void main(void)
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MICROKERNEL || CONFIG_NANOKERNEL */
|
Loading…
Add table
Add a link
Reference in a new issue