1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #14702 from maribu/sched_active_thread

treewide: Fix direct access to scheduler internals
This commit is contained in:
Francisco 2020-09-21 09:09:59 +02:00 committed by GitHub
commit 64f6b7ffa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 16 deletions

View File

@ -183,21 +183,11 @@ extern volatile unsigned int sched_context_switch_request;
*/
extern volatile thread_t *sched_threads[KERNEL_PID_LAST + 1];
/**
* Currently active thread
*/
extern volatile thread_t *sched_active_thread;
/**
* Number of running (non-terminated) threads
*/
extern volatile int sched_num_threads;
/**
* Process ID of active thread
*/
extern volatile kernel_pid_t sched_active_pid;
/**
* List of runqueues per priority level
*/

View File

@ -103,6 +103,7 @@ BaseType_t xTaskCreate (TaskFunction_t pvTaskCode,
void vTaskDelete (TaskHandle_t xTaskToDelete)
{
extern volatile thread_t *sched_active_thread;
DEBUG("%s pid=%d task=%p\n", __func__, thread_getpid(), xTaskToDelete);
assert(xTaskToDelete != NULL);

View File

@ -416,6 +416,8 @@ NORETURN void cpu_switch_context_exit(void)
*/
NORETURN void task_exit(void)
{
extern volatile thread_t *sched_active_thread;
extern volatile kernel_pid_t sched_active_pid;
DEBUG("sched_task_exit: ending thread %" PRIkernel_pid "...\n",
thread_getpid());

View File

@ -71,7 +71,7 @@ static int _init(netdev_t *netdev)
{
kw2xrf_t *dev = (kw2xrf_t *)netdev;
dev->thread = (thread_t *)thread_get(thread_getpid());
dev->thread = thread_get_active();
/* initialize SPI and GPIOs */
if (kw2xrf_init(dev, &_irq_handler)) {

View File

@ -86,7 +86,7 @@ static void kw41zrf_irq_handler(void *arg)
static int kw41zrf_netdev_init(netdev_t *netdev)
{
kw41zrf_t *dev = (kw41zrf_t *)netdev;
dev->thread = (thread_t *)thread_get(thread_getpid());
dev->thread = thread_get_active();
/* initialize hardware */
if (kw41zrf_init(dev, kw41zrf_irq_handler)) {

View File

@ -48,7 +48,8 @@ int main()
THREAD_CREATE_WOUT_YIELD,
threadA_func, NULL, "thread A");
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n", sched_active_pid);
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n",
thread_getpid());
printf("We'll test C++ class and methods here!\n");
cpp_class cpp_obj;
@ -83,7 +84,8 @@ void *threadA_func(void *)
int day = 13, month = 6, year = 2014;
int ret_day;
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n", sched_active_pid);
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n",
thread_getpid());
printf("We'll test some C functions here!\n");
printf("\n-= hello function =-\n");

View File

@ -162,6 +162,6 @@ void lvgl_init(screen_dev_t *screen_dev)
void lvgl_wakeup(void)
{
thread_t *tcb = (thread_t *)sched_threads[_task_thread_pid];
thread_t *tcb = thread_get(_task_thread_pid);
thread_flags_set(tcb, LVGL_THREAD_FLAG);
}

View File

@ -93,7 +93,7 @@ static void _netif_init(gnrc_netif_t *netif)
gnrc_netif_default_init(netif);
/* save the threads context pointer, so we can set its flags */
_netif_thread = (thread_t *)thread_get(thread_getpid());
_netif_thread = thread_get_active();
#if IS_USED(MODULE_GNRC_NETIF_6LO)
/* we disable fragmentation for this device, as the L2CAP layer takes care