forked from Imagelibrary/rtems
score: Add scheduler <sys/lock.h> support
This commit is contained in:
@@ -350,6 +350,7 @@ libscore_a_SOURCES += src/profilingisrentryexit.c
|
|||||||
libscore_a_SOURCES += src/mutex.c
|
libscore_a_SOURCES += src/mutex.c
|
||||||
libscore_a_SOURCES += src/once.c
|
libscore_a_SOURCES += src/once.c
|
||||||
libscore_a_SOURCES += src/resourceiterate.c
|
libscore_a_SOURCES += src/resourceiterate.c
|
||||||
|
libscore_a_SOURCES += src/sched.c
|
||||||
libscore_a_SOURCES += src/semaphore.c
|
libscore_a_SOURCES += src/semaphore.c
|
||||||
libscore_a_SOURCES += src/smpbarrierwait.c
|
libscore_a_SOURCES += src/smpbarrierwait.c
|
||||||
libscore_a_SOURCES += src/kern_tc.c
|
libscore_a_SOURCES += src/kern_tc.c
|
||||||
|
|||||||
70
cpukit/score/src/sched.c
Normal file
70
cpukit/score/src/sched.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 embedded brains GmbH. All rights reserved.
|
||||||
|
*
|
||||||
|
* embedded brains GmbH
|
||||||
|
* Dornierstr. 4
|
||||||
|
* 82178 Puchheim
|
||||||
|
* Germany
|
||||||
|
* <rtems@embedded-brains.de>
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.org/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/lock.h>
|
||||||
|
|
||||||
|
#include <rtems/score/schedulerimpl.h>
|
||||||
|
|
||||||
|
#if HAVE_STRUCT__THREAD_QUEUE_QUEUE
|
||||||
|
|
||||||
|
int _Sched_Count( void )
|
||||||
|
{
|
||||||
|
return (int) _Scheduler_Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _Sched_Index( void )
|
||||||
|
{
|
||||||
|
Thread_Control *executing = _Thread_Get_executing();
|
||||||
|
|
||||||
|
return (int) _Scheduler_Get_index( _Scheduler_Get( executing ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int _Sched_Name_to_index( const char *name, size_t len )
|
||||||
|
{
|
||||||
|
uint32_t name_32 = 0;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
while ( i < 4 && i < len ) {
|
||||||
|
name_32 |= ( (uint32_t) ( (uint8_t) *name ) ) << ( ( 3 - i ) * 8 );
|
||||||
|
++name;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0 ; i < _Scheduler_Count ; ++i ) {
|
||||||
|
const Scheduler_Control *scheduler = &_Scheduler_Table[ i ];
|
||||||
|
|
||||||
|
if ( scheduler->name == name_32 ) {
|
||||||
|
return (int) i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _Sched_Processor_count( int index )
|
||||||
|
{
|
||||||
|
size_t i = (size_t) index;
|
||||||
|
|
||||||
|
if ( i < _Scheduler_Count ) {
|
||||||
|
return _Scheduler_Get_processor_count( &_Scheduler_Table[ i ] );
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_STRUCT__THREAD_QUEUE_QUEUE */
|
||||||
@@ -389,6 +389,20 @@ static void test_futex(test_context *ctx)
|
|||||||
rtems_test_assert(ctx->eno[b] == 0);
|
rtems_test_assert(ctx->eno[b] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_sched(void)
|
||||||
|
{
|
||||||
|
rtems_test_assert(_Sched_Index() == 0);
|
||||||
|
rtems_test_assert(_Sched_Name_to_index("", 0) == -1);
|
||||||
|
rtems_test_assert(_Sched_Name_to_index("b", 1) == -1);
|
||||||
|
rtems_test_assert(_Sched_Name_to_index("bl", 2) == -1);
|
||||||
|
rtems_test_assert(_Sched_Name_to_index("blu", 3) == -1);
|
||||||
|
rtems_test_assert(_Sched_Name_to_index("blue", 4) == 0);
|
||||||
|
rtems_test_assert(_Sched_Name_to_index("blueX", 5) == 0);
|
||||||
|
rtems_test_assert(_Sched_Processor_count(-1) == 0);
|
||||||
|
rtems_test_assert(_Sched_Processor_count(0) == 1);
|
||||||
|
rtems_test_assert(_Sched_Processor_count(1) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void mid_task(rtems_task_argument arg)
|
static void mid_task(rtems_task_argument arg)
|
||||||
{
|
{
|
||||||
rtems_test_assert(0);
|
rtems_test_assert(0);
|
||||||
@@ -532,6 +546,7 @@ static void test(void)
|
|||||||
test_sem(ctx);
|
test_sem(ctx);
|
||||||
test_sem_prio_wait_order(ctx);
|
test_sem_prio_wait_order(ctx);
|
||||||
test_futex(ctx);
|
test_futex(ctx);
|
||||||
|
test_sched();
|
||||||
|
|
||||||
send_event(ctx, 0, EVENT_MTX_DEADLOCK);
|
send_event(ctx, 0, EVENT_MTX_DEADLOCK);
|
||||||
|
|
||||||
@@ -567,6 +582,8 @@ static void Init(rtems_task_argument arg)
|
|||||||
|
|
||||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||||
|
|
||||||
|
#define CONFIGURE_SCHEDULER_NAME rtems_build_name('b', 'l', 'u', 'e')
|
||||||
|
|
||||||
#define CONFIGURE_INIT
|
#define CONFIGURE_INIT
|
||||||
|
|
||||||
#include <rtems/confdefs.h>
|
#include <rtems/confdefs.h>
|
||||||
|
|||||||
@@ -22,9 +22,14 @@ directives:
|
|||||||
- _Futex_Wait()
|
- _Futex_Wait()
|
||||||
- _Futex_Wake()
|
- _Futex_Wake()
|
||||||
- _Futex_Destroy()
|
- _Futex_Destroy()
|
||||||
|
- _Sched_Count()
|
||||||
|
- _Sched_Index()
|
||||||
|
- _Sched_Name_to_index()
|
||||||
|
- _Sched_Processor_count()
|
||||||
|
|
||||||
concepts:
|
concepts:
|
||||||
|
|
||||||
- Ensure that self-contained mutexes and recursive mutexes work.
|
- Ensure that self-contained mutexes and recursive mutexes work.
|
||||||
- Ensure that self-contained semaphores work.
|
- Ensure that self-contained semaphores work.
|
||||||
- Ensure that self-contained futexes work.
|
- Ensure that self-contained futexes work.
|
||||||
|
- Ensure that <sys/lock.h> scheduler support works.
|
||||||
|
|||||||
Reference in New Issue
Block a user