ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Понедельник
22 июля
1260820 Топик полностью
Dingo (21.11.2022 05:45, просмотров: 168) ответил Dingo на Есть легковесная версия RT-Thread Nano: It has a very small size and refined hard real-time kernel, and which requires only 3 KB of ROM and 1.2 KB of RAM.
Вот фрагмент кода, который выполняется при вызове задержки. 

/** * This function will let current thread sleep for some ticks. * * @param tick the sleep ticks * * @return RT_EOK */ rt_err_t rt_thread_sleep(rt_tick_t tick) { register rt_base_t temp; struct rt_thread *thread; /* disable interrupt */ temp = rt_hw_interrupt_disable(); /* set to current thread */ thread = rt_current_thread; RT_ASSERT(thread != RT_NULL); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); /* suspend thread */ rt_thread_suspend(thread); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &tick); rt_timer_start(&(thread->thread_timer)); /* enable interrupt */ rt_hw_interrupt_enable(temp); rt_schedule(); /* clear error number of this thread to RT_EOK */ if (thread->error == -RT_ETIMEOUT) thread->error = RT_EOK; return RT_EOK; }


При переключении задачи запрещает прерывания, если я всё верно понял.