mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 21:34:25 +08:00
Add and use rtems_bsd_get_task_priority()
This commit is contained in:
1
Makefile
1
Makefile
@@ -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-delay.c
|
||||||
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-ethernet-addr.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-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-init.c
|
||||||
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-jail.c
|
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-jail.c
|
||||||
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-kern_synch.c
|
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-kern_synch.c
|
||||||
|
@@ -669,6 +669,7 @@ rtems.addRTEMSSourceFiles(
|
|||||||
'rtems/rtems-bsd-delay.c',
|
'rtems/rtems-bsd-delay.c',
|
||||||
'rtems/rtems-bsd-get-ethernet-addr.c',
|
'rtems/rtems-bsd-get-ethernet-addr.c',
|
||||||
'rtems/rtems-bsd-get-file.c',
|
'rtems/rtems-bsd-get-file.c',
|
||||||
|
'rtems/rtems-bsd-get-task-priority.c',
|
||||||
'rtems/rtems-bsd-init.c',
|
'rtems/rtems-bsd-init.c',
|
||||||
'rtems/rtems-bsd-jail.c',
|
'rtems/rtems-bsd-jail.c',
|
||||||
'rtems/rtems-bsd-kern_synch.c',
|
'rtems/rtems-bsd-kern_synch.c',
|
||||||
|
@@ -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
|
using `rtems_bsd_command_route()`. For an example please have a look at
|
||||||
`testsuite/include/rtems/bsd/test/default-network-init.h`.
|
`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
|
== Network Stack Features
|
||||||
|
|
||||||
http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client
|
http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client
|
||||||
|
@@ -50,14 +50,6 @@
|
|||||||
|
|
||||||
#define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D')
|
#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 */
|
/* FIXME */
|
||||||
#define BSD_MINIMUM_TASK_STACK_SIZE ((size_t) 32 * 1024)
|
#define BSD_MINIMUM_TASK_STACK_SIZE ((size_t) 32 * 1024)
|
||||||
|
|
||||||
|
@@ -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
|
* embedded brains GmbH
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
@@ -77,6 +77,19 @@ typedef struct {
|
|||||||
|
|
||||||
rtems_status_code rtems_bsd_initialize(void);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
54
rtemsbsd/rtems/rtems-bsd-get-task-priority.c
Normal file
54
rtemsbsd/rtems/rtems-bsd-get-task-priority.c
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@@ -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
|
* embedded brains GmbH
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
@@ -76,7 +76,8 @@ struct timeval boottime;
|
|||||||
rtems_status_code
|
rtems_status_code
|
||||||
rtems_bsd_initialize(void)
|
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();
|
hz = (int) rtems_clock_get_ticks_per_second();
|
||||||
tick = 1000000 / hz;
|
tick = 1000000 / hz;
|
||||||
@@ -88,7 +89,7 @@ rtems_bsd_initialize(void)
|
|||||||
mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
|
mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
|
|
||||||
sc = rtems_timer_initiate_server(
|
sc = rtems_timer_initiate_server(
|
||||||
BSD_TASK_PRIORITY_TIMER,
|
rtems_bsd_get_task_priority(name),
|
||||||
BSD_MINIMUM_TASK_STACK_SIZE,
|
BSD_MINIMUM_TASK_STACK_SIZE,
|
||||||
RTEMS_DEFAULT_ATTRIBUTES
|
RTEMS_DEFAULT_ATTRIBUTES
|
||||||
);
|
);
|
||||||
|
@@ -36,9 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
#include <rtems/bsd/bsd.h>
|
||||||
|
|
||||||
static uint32_t networkDaemonPriority = 100; /* XXX */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure passed to task-start stub
|
* 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);
|
strncpy (nm, name, 4);
|
||||||
sc = rtems_task_create (rtems_build_name(nm[0], nm[1], nm[2], nm[3]),
|
sc = rtems_task_create (rtems_build_name(nm[0], nm[1], nm[2], nm[3]),
|
||||||
networkDaemonPriority,
|
rtems_bsd_get_task_priority(name),
|
||||||
stacksize,
|
stacksize,
|
||||||
RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
|
RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
|
||||||
RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
|
RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
|
||||||
|
@@ -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
|
* embedded brains GmbH
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
@@ -69,6 +69,7 @@ static struct rman irq_rman;
|
|||||||
static int
|
static int
|
||||||
nexus_probe(device_t dev)
|
nexus_probe(device_t dev)
|
||||||
{
|
{
|
||||||
|
static const char name[] = "IRQS";
|
||||||
rtems_status_code status;
|
rtems_status_code status;
|
||||||
int err;
|
int err;
|
||||||
const rtems_bsd_device *nd;
|
const rtems_bsd_device *nd;
|
||||||
@@ -77,7 +78,7 @@ nexus_probe(device_t dev)
|
|||||||
|
|
||||||
#ifndef DISABLE_INTERRUPT_EXTENSION
|
#ifndef DISABLE_INTERRUPT_EXTENSION
|
||||||
status = rtems_interrupt_server_initialize(
|
status = rtems_interrupt_server_initialize(
|
||||||
BSD_TASK_PRIORITY_INTERRUPT,
|
rtems_bsd_get_task_priority(name),
|
||||||
BSD_MINIMUM_TASK_STACK_SIZE,
|
BSD_MINIMUM_TASK_STACK_SIZE,
|
||||||
RTEMS_DEFAULT_MODES,
|
RTEMS_DEFAULT_MODES,
|
||||||
RTEMS_DEFAULT_ATTRIBUTES,
|
RTEMS_DEFAULT_ATTRIBUTES,
|
||||||
|
@@ -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
|
* embedded brains GmbH
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
@@ -50,6 +50,8 @@
|
|||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/selinfo.h>
|
#include <sys/selinfo.h>
|
||||||
|
|
||||||
|
#include <rtems/bsd/bsd.h>
|
||||||
|
|
||||||
#include <rtems/score/objectimpl.h>
|
#include <rtems/score/objectimpl.h>
|
||||||
#include <rtems/score/statesimpl.h>
|
#include <rtems/score/statesimpl.h>
|
||||||
#include <rtems/score/threaddispatch.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;
|
int eno = 0;
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_id task_id;
|
rtems_id task_id;
|
||||||
|
struct thread *td;
|
||||||
|
char name[sizeof(td->td_name)];
|
||||||
|
|
||||||
BSD_ASSERT(pages >= 0);
|
BSD_ASSERT(pages >= 0);
|
||||||
|
|
||||||
|
vsnprintf(name, sizeof(name), fmt, ap);
|
||||||
|
|
||||||
sc = rtems_task_create(
|
sc = rtems_task_create(
|
||||||
BSD_TASK_NAME,
|
BSD_TASK_NAME,
|
||||||
BSD_TASK_PRIORITY_NORMAL,
|
rtems_bsd_get_task_priority(name),
|
||||||
BSD_MINIMUM_TASK_STACK_SIZE + (size_t) pages * PAGE_SIZE,
|
BSD_MINIMUM_TASK_STACK_SIZE + (size_t) pages * PAGE_SIZE,
|
||||||
RTEMS_DEFAULT_MODES,
|
RTEMS_DEFAULT_MODES,
|
||||||
RTEMS_DEFAULT_ATTRIBUTES,
|
RTEMS_DEFAULT_ATTRIBUTES,
|
||||||
@@ -259,14 +265,13 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg,
|
|||||||
);
|
);
|
||||||
if (sc == RTEMS_SUCCESSFUL) {
|
if (sc == RTEMS_SUCCESSFUL) {
|
||||||
Thread_Control *thread = rtems_bsd_get_thread_by_id(task_id);
|
Thread_Control *thread = rtems_bsd_get_thread_by_id(task_id);
|
||||||
struct thread *td;
|
|
||||||
|
|
||||||
BSD_ASSERT(thread != NULL);
|
BSD_ASSERT(thread != NULL);
|
||||||
|
|
||||||
td = rtems_bsd_get_thread(thread);
|
td = rtems_bsd_get_thread(thread);
|
||||||
BSD_ASSERT(td != NULL);
|
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) {
|
if (rtems_bsd_thread_ready_to_start) {
|
||||||
sc = rtems_task_start(task_id, (rtems_task_entry) func,
|
sc = rtems_task_start(task_id, (rtems_task_entry) func,
|
||||||
|
Reference in New Issue
Block a user