Add and use rtems_bsd_get_task_priority()

This commit is contained in:
Sebastian Huber
2015-01-20 08:39:06 +01:00
parent e6405ea0cb
commit 91ea7ea614
10 changed files with 96 additions and 22 deletions

View File

@@ -71,6 +71,7 @@ LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-conf.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-delay.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-ethernet-addr.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-task-priority.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-jail.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-kern_synch.c

View File

@@ -669,6 +669,7 @@ rtems.addRTEMSSourceFiles(
'rtems/rtems-bsd-delay.c',
'rtems/rtems-bsd-get-ethernet-addr.c',
'rtems/rtems-bsd-get-file.c',
'rtems/rtems-bsd-get-task-priority.c',
'rtems/rtems-bsd-init.c',
'rtems/rtems-bsd-jail.c',
'rtems/rtems-bsd-kern_synch.c',

View File

@@ -228,6 +228,14 @@ http://www.freebsd.org/cgi/man.cgi?query=route&apropos=0&sektion=8&manpath=FreeB
using `rtems_bsd_command_route()`. For an example please have a look at
`testsuite/include/rtems/bsd/test/default-network-init.h`.
=== Task Priorities and Stack Size ===
The default task priority is 96 for the interrupt server task (name "IRQS"), 98
for the timer server task (name "TIME") and 100 for all other tasks. The
application may provide their own implementation of the
`rtems_bsd_get_task_priority()` function (for example in the module which calls
`rtems_bsd_initialize()`) if different values are desired.
== Network Stack Features
http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client

View File

@@ -50,14 +50,6 @@
#define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D')
#define BSD_TASK_PRIORITY_NORMAL 120
#define BSD_TASK_PRIORITY_TIMER 110
#define BSD_TASK_PRIORITY_INTERRUPT 100
#define BSD_TASK_PRIORITY_RESOURCE_OWNER 100
/* FIXME */
#define BSD_MINIMUM_TASK_STACK_SIZE ((size_t) 32 * 1024)

View File

@@ -7,7 +7,7 @@
*/
/*
* Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
* Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -77,6 +77,19 @@ typedef struct {
rtems_status_code rtems_bsd_initialize(void);
/**
* @brief Returns the initial priority for a task specified by its name.
*
* Applications may provide their own implementation of this function. For
* example they can define their implementation in the same module which calls
* rtems_bsd_initialize().
*
* @param[in] name The task name.
*
* @return The desired initial task priority.
*/
rtems_task_priority rtems_bsd_get_task_priority(const char *name);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -0,0 +1,54 @@
/**
* @file
*
* @ingroup rtems_bsd_rtems
*
* @brief TODO.
*/
/*
* Copyright (c) 2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <rtems/bsd/bsd.h>
#include <string.h>
rtems_task_priority
rtems_bsd_get_task_priority(const char *name)
{
if (strcmp(name, "IRQS") == 0) {
return (96);
} else if (strcmp(name, "TIME") == 0) {
return (98);
} else {
return (100);
}
}

View File

@@ -7,7 +7,7 @@
*/
/*
* Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
* Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -76,7 +76,8 @@ struct timeval boottime;
rtems_status_code
rtems_bsd_initialize(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
static const char name[] = "TIME";
rtems_status_code sc;
hz = (int) rtems_clock_get_ticks_per_second();
tick = 1000000 / hz;
@@ -88,7 +89,7 @@ rtems_bsd_initialize(void)
mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
sc = rtems_timer_initiate_server(
BSD_TASK_PRIORITY_TIMER,
rtems_bsd_get_task_priority(name),
BSD_MINIMUM_TASK_STACK_SIZE,
RTEMS_DEFAULT_ATTRIBUTES
);

View File

@@ -36,9 +36,7 @@
#include <string.h>
#include <stdio.h>
#include <rtems.h>
static uint32_t networkDaemonPriority = 100; /* XXX */
#include <rtems/bsd/bsd.h>
/*
* Structure passed to task-start stub
@@ -88,7 +86,7 @@ rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg
strncpy (nm, name, 4);
sc = rtems_task_create (rtems_build_name(nm[0], nm[1], nm[2], nm[3]),
networkDaemonPriority,
rtems_bsd_get_task_priority(name),
stacksize,
RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,

View File

@@ -7,7 +7,7 @@
*/
/*
* Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved.
* Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -69,6 +69,7 @@ static struct rman irq_rman;
static int
nexus_probe(device_t dev)
{
static const char name[] = "IRQS";
rtems_status_code status;
int err;
const rtems_bsd_device *nd;
@@ -77,7 +78,7 @@ nexus_probe(device_t dev)
#ifndef DISABLE_INTERRUPT_EXTENSION
status = rtems_interrupt_server_initialize(
BSD_TASK_PRIORITY_INTERRUPT,
rtems_bsd_get_task_priority(name),
BSD_MINIMUM_TASK_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES,

View File

@@ -7,7 +7,7 @@
*/
/*
* Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
* Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -50,6 +50,8 @@
#include <sys/malloc.h>
#include <sys/selinfo.h>
#include <rtems/bsd/bsd.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/statesimpl.h>
#include <rtems/score/threaddispatch.h>
@@ -246,12 +248,16 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg,
int eno = 0;
rtems_status_code sc;
rtems_id task_id;
struct thread *td;
char name[sizeof(td->td_name)];
BSD_ASSERT(pages >= 0);
vsnprintf(name, sizeof(name), fmt, ap);
sc = rtems_task_create(
BSD_TASK_NAME,
BSD_TASK_PRIORITY_NORMAL,
rtems_bsd_get_task_priority(name),
BSD_MINIMUM_TASK_STACK_SIZE + (size_t) pages * PAGE_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES,
@@ -259,14 +265,13 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg,
);
if (sc == RTEMS_SUCCESSFUL) {
Thread_Control *thread = rtems_bsd_get_thread_by_id(task_id);
struct thread *td;
BSD_ASSERT(thread != NULL);
td = rtems_bsd_get_thread(thread);
BSD_ASSERT(td != NULL);
vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap);
memcpy(td->td_name, name, sizeof(name));
if (rtems_bsd_thread_ready_to_start) {
sc = rtems_task_start(task_id, (rtems_task_entry) func,