RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
rtthread.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2024 RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2006-03-18 Bernard the first version
9 * 2006-04-26 Bernard add semaphore APIs
10 * 2006-08-10 Bernard add version information
11 * 2007-01-28 Bernard rename RT_OBJECT_Class_Static to RT_Object_Class_Static
12 * 2007-03-03 Bernard clean up the definitions to rtdef.h
13 * 2010-04-11 yi.qiu add module feature
14 * 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE.
15 * 2016-08-09 ArdaFu add new thread and interrupt hook.
16 * 2018-11-22 Jesven add all cpu's lock and ipi handler
17 * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB
18 * 2021-11-14 Meco Man add rtlegacy.h for compatibility
19 * 2022-06-04 Meco Man remove strnlen
20 * 2023-05-20 Bernard add rtatomic.h header file to included files.
21 * 2023-06-30 ChuShicheng move debug check from the rtdebug.h
22 * 2023-10-16 Shell Support a new backtrace framework
23 * 2023-12-10 xqyjlj fix spinlock in up
24 * 2024-01-25 Shell Add rt_susp_list for IPC primitives
25 * 2024-03-10 Meco Man move std libc related functions to rtklibc
26 */
27
28#ifndef __RT_THREAD_H__
29#define __RT_THREAD_H__
30
31#include <rtconfig.h>
32#include <rtdef.h>
33#include <rtservice.h>
34#include <rtm.h>
35#include <rtatomic.h>
36#include <rtklibc.h>
37#ifdef RT_USING_LEGACY
38#include <rtlegacy.h>
39#endif
40#ifdef RT_USING_FINSH
41#include <finsh.h>
42#endif /* RT_USING_FINSH */
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#ifdef __GNUC__
49int entry(void);
50#endif
51
56
57/*
58 * kernel object interface
59 */
63int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen);
64
65void rt_object_init(struct rt_object *object,
67 const char *name);
68void rt_object_detach(rt_object_t object);
69#ifdef RT_USING_HEAP
71void rt_object_delete(rt_object_t object);
72/* custom object */
73rt_object_t rt_custom_object_create(const char *name, void *data, rt_err_t (*data_destroy)(void *));
75#endif /* RT_USING_HEAP */
79rt_object_t rt_object_find(const char *name, rt_uint8_t type);
80rt_err_t rt_object_get_name(rt_object_t object, char *name, rt_uint8_t name_size);
81
82#ifdef RT_USING_HOOK
83void rt_object_attach_sethook(void (*hook)(struct rt_object *object));
84void rt_object_detach_sethook(void (*hook)(struct rt_object *object));
85void rt_object_trytake_sethook(void (*hook)(struct rt_object *object));
86void rt_object_take_sethook(void (*hook)(struct rt_object *object));
87void rt_object_put_sethook(void (*hook)(struct rt_object *object));
88#endif /* RT_USING_HOOK */
89
91
96
97/*
98 * clock & timer interface
99 */
101void rt_tick_set(rt_tick_t tick);
102void rt_tick_increase(void);
106#ifdef RT_USING_HOOK
107void rt_tick_sethook(void (*hook)(void));
108#endif /* RT_USING_HOOK */
109
110void rt_system_timer_init(void);
112
113void rt_timer_init(rt_timer_t timer,
114 const char *name,
115 void (*timeout)(void *parameter),
116 void *parameter,
117 rt_tick_t time,
118 rt_uint8_t flag);
120#ifdef RT_USING_HEAP
121rt_timer_t rt_timer_create(const char *name,
122 void (*timeout)(void *parameter),
123 void *parameter,
124 rt_tick_t time,
125 rt_uint8_t flag);
127#endif /* RT_USING_HEAP */
130rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg);
132void rt_timer_check(void);
133#ifdef RT_USING_HOOK
134void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer));
135void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer));
136#endif /* RT_USING_HOOK */
137
139
144
145/*
146 * thread interface
147 */
148rt_err_t rt_thread_init(struct rt_thread *thread,
149 const char *name,
150 void (*entry)(void *parameter),
151 void *parameter,
152 void *stack_start,
153 rt_uint32_t stack_size,
154 rt_uint8_t priority,
155 rt_uint32_t tick);
157#ifdef RT_USING_HEAP
158rt_thread_t rt_thread_create(const char *name,
159 void (*entry)(void *parameter),
160 void *parameter,
161 rt_uint32_t stack_size,
162 rt_uint8_t priority,
163 rt_uint32_t tick);
165#endif /* RT_USING_HEAP */
168rt_thread_t rt_thread_find(char *name);
174rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg);
176rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag);
178#ifdef RT_USING_SMART
179rt_err_t rt_thread_wakeup(rt_thread_t thread);
180void rt_thread_wakeup_set(struct rt_thread *thread, rt_wakeup_func_t func, void* user_data);
181#endif /* RT_USING_SMART */
182rt_err_t rt_thread_get_name(rt_thread_t thread, char *name, rt_uint8_t name_size);
183#ifdef RT_USING_SIGNALS
184void rt_thread_alloc_sig(rt_thread_t tid);
185void rt_thread_free_sig(rt_thread_t tid);
186int rt_thread_kill(rt_thread_t tid, int sig);
187#endif /* RT_USING_SIGNALS */
188#ifdef RT_USING_HOOK
189void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread));
190void rt_thread_resume_sethook (void (*hook)(rt_thread_t thread));
191
199
200#endif /* RT_USING_HOOK */
201
202/*
203 * idle thread interface
204 */
205void rt_thread_idle_init(void);
206#if defined(RT_USING_HOOK) || defined(RT_USING_IDLE_HOOK)
208rt_err_t rt_thread_idle_delhook(void (*hook)(void));
209#endif /* defined(RT_USING_HOOK) || defined(RT_USING_IDLE_HOOK) */
211
212/*
213 * schedule service
214 */
215void rt_system_scheduler_init(void);
217
218void rt_schedule(void);
219void rt_scheduler_do_irq_switch(void *context);
220
221#ifdef RT_USING_OVERFLOW_CHECK
222void rt_scheduler_stack_check(struct rt_thread *thread);
223
224#define RT_SCHEDULER_STACK_CHECK(thr) rt_scheduler_stack_check(thr)
225
226#else /* !RT_USING_OVERFLOW_CHECK */
227
228#define RT_SCHEDULER_STACK_CHECK(thr)
229
230#endif /* RT_USING_OVERFLOW_CHECK */
231
234void rt_exit_critical_safe(rt_base_t critical_level);
236
237#ifdef RT_USING_HOOK
238void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to));
239void rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid));
240#endif /* RT_USING_HOOK */
241
242#ifdef RT_USING_SMP
243void rt_secondary_cpu_entry(void);
244void rt_scheduler_ipi_handler(int vector, void *param);
245#endif /* RT_USING_SMP */
246
248
253#ifdef RT_USING_SIGNALS
254void rt_signal_mask(int signo);
255void rt_signal_unmask(int signo);
256rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler);
257int rt_signal_wait(const rt_sigset_t *set, rt_siginfo_t *si, rt_int32_t timeout);
258int rt_system_signal_init(void);
259#endif /* RT_USING_SIGNALS */
261
266
267/*
268 * memory management interface
269 */
270#ifdef RT_USING_MEMPOOL
271/*
272 * memory pool interface
273 */
275 const char *name,
276 void *start,
277 rt_size_t size,
278 rt_size_t block_size);
280#ifdef RT_USING_HEAP
281rt_mp_t rt_mp_create(const char *name,
282 rt_size_t block_count,
283 rt_size_t block_size);
285#endif /* RT_USING_HEAP */
286void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time);
287void rt_mp_free(void *block);
288#ifdef RT_USING_HOOK
289void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool *mp, void *block));
290void rt_mp_free_sethook(void (*hook)(struct rt_mempool *mp, void *block));
291#endif /* RT_USING_HOOK */
292
293#endif /* RT_USING_MEMPOOL */
294
295#ifdef RT_USING_HEAP
296/*
297 * heap memory interface
298 */
299void rt_system_heap_init(void *begin_addr, void *end_addr);
300void rt_system_heap_init_generic(void *begin_addr, void *end_addr);
301
302void *rt_malloc(rt_size_t size);
303void rt_free(void *ptr);
304void *rt_realloc(void *ptr, rt_size_t newsize);
305void *rt_calloc(rt_size_t count, rt_size_t size);
306void *rt_malloc_align(rt_size_t size, rt_size_t align);
307void rt_free_align(void *ptr);
308
309void rt_memory_info(rt_size_t *total,
310 rt_size_t *used,
311 rt_size_t *max_used);
312
313#if defined(RT_USING_SLAB) && defined(RT_USING_SLAB_AS_HEAP)
314void *rt_page_alloc(rt_size_t npages);
315void rt_page_free(void *addr, rt_size_t npages);
316#endif /* defined(RT_USING_SLAB) && defined(RT_USING_SLAB_AS_HEAP) */
317
322
323#ifdef RT_USING_HOOK
324void rt_malloc_sethook(void (*hook)(void **ptr, rt_size_t size));
325void rt_realloc_set_entry_hook(void (*hook)(void **ptr, rt_size_t size));
326void rt_realloc_set_exit_hook(void (*hook)(void **ptr, rt_size_t size));
327void rt_free_sethook(void (*hook)(void **ptr));
328#endif /* RT_USING_HOOK */
330
331#endif /* RT_USING_HEAP */
332
333#ifdef RT_USING_SMALL_MEM
337rt_smem_t rt_smem_init(const char *name,
338 void *begin_addr,
339 rt_size_t size);
341void *rt_smem_alloc(rt_smem_t m, rt_size_t size);
342void *rt_smem_realloc(rt_smem_t m, void *rmem, rt_size_t newsize);
343void rt_smem_free(void *rmem);
344#endif /* RT_USING_SMALL_MEM */
345
346#ifdef RT_USING_MEMHEAP
350rt_err_t rt_memheap_init(struct rt_memheap *memheap,
351 const char *name,
352 void *start_addr,
353 rt_size_t size);
354rt_err_t rt_memheap_detach(struct rt_memheap *heap);
355void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size);
356void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize);
357void rt_memheap_free(void *ptr);
358void rt_memheap_info(struct rt_memheap *heap,
359 rt_size_t *total,
360 rt_size_t *used,
361 rt_size_t *max_used);
362#endif /* RT_USING_MEMHEAP */
363
364#ifdef RT_USING_MEMHEAP_AS_HEAP
368void *_memheap_alloc(struct rt_memheap *heap, rt_size_t size);
369void _memheap_free(void *rmem);
370void *_memheap_realloc(struct rt_memheap *heap, void *rmem, rt_size_t newsize);
371#endif
372
373#ifdef RT_USING_SLAB
377rt_slab_t rt_slab_init(const char *name, void *begin_addr, rt_size_t size);
378rt_err_t rt_slab_detach(rt_slab_t m);
379void *rt_slab_page_alloc(rt_slab_t m, rt_size_t npages);
380void rt_slab_page_free(rt_slab_t m, void *addr, rt_size_t npages);
381void *rt_slab_alloc(rt_slab_t m, rt_size_t size);
382void *rt_slab_realloc(rt_slab_t m, void *ptr, rt_size_t size);
383void rt_slab_free(rt_slab_t m, void *ptr);
384#endif /* RT_USING_SLAB */
385
387
392
399void rt_susp_list_print(rt_list_t *list);
400/* reserve thread error while resuming it */
401#define RT_THREAD_RESUME_RES_THR_ERR (-1)
402struct rt_thread *rt_susp_list_dequeue(rt_list_t *susp_list, rt_err_t thread_error);
403rt_err_t rt_susp_list_resume_all(rt_list_t *susp_list, rt_err_t thread_error);
405 rt_err_t thread_error,
406 struct rt_spinlock *lock);
407
408/* suspend and enqueue */
409rt_err_t rt_thread_suspend_to_list(rt_thread_t thread, rt_list_t *susp_list, int ipc_flags, int suspend_flag);
410/* only for a suspended thread, and caller must hold the scheduler lock */
411rt_err_t rt_susp_list_enqueue(rt_list_t *susp_list, rt_thread_t thread, int ipc_flags);
412
417
418#ifdef RT_USING_SEMAPHORE
419/*
420 * semaphore interface
421 */
423 const char *name,
424 rt_uint32_t value,
425 rt_uint8_t flag);
427#ifdef RT_USING_HEAP
428rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag);
430#endif /* RT_USING_HEAP */
431
437rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg);
438#endif /* RT_USING_SEMAPHORE */
439
441
446
447#ifdef RT_USING_MUTEX
448/*
449 * mutex interface
450 */
451rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag);
453#ifdef RT_USING_HEAP
454rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag);
456#endif /* RT_USING_HEAP */
460
466rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg);
467
469{
470 return mutex->owner;
471}
473{
474 return mutex->hold;
475}
476
477#endif /* RT_USING_MUTEX */
478
480
485
486#ifdef RT_USING_EVENT
487/*
488 * event interface
489 */
490rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag);
492#ifdef RT_USING_HEAP
493rt_event_t rt_event_create(const char *name, rt_uint8_t flag);
495#endif /* RT_USING_HEAP */
496
499 rt_uint32_t set,
500 rt_uint8_t opt,
501 rt_int32_t timeout,
502 rt_uint32_t *recved);
504 rt_uint32_t set,
505 rt_uint8_t opt,
506 rt_int32_t timeout,
507 rt_uint32_t *recved);
509 rt_uint32_t set,
510 rt_uint8_t opt,
511 rt_int32_t timeout,
512 rt_uint32_t *recved);
513rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg);
514#endif /* RT_USING_EVENT */
515
517
522
523#ifdef RT_USING_MAILBOX
524/*
525 * mailbox interface
526 */
528 const char *name,
529 void *msgpool,
530 rt_size_t size,
531 rt_uint8_t flag);
533#ifdef RT_USING_HEAP
534rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag);
536#endif /* RT_USING_HEAP */
537
542 rt_ubase_t value,
543 rt_int32_t timeout);
545 rt_ubase_t value,
546 rt_int32_t timeout);
548 rt_ubase_t value,
549 rt_int32_t timeout);
554rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg);
555#endif /* RT_USING_MAILBOX */
556
558
563#ifdef RT_USING_MESSAGEQUEUE
564
566{
569#ifdef RT_USING_MESSAGEQUEUE_PRIORITY
570 rt_int32_t prio;
571#endif /* RT_USING_MESSAGEQUEUE_PRIORITY */
572};
573
574#define RT_MQ_BUF_SIZE(msg_size, max_msgs) \
575((RT_ALIGN((msg_size), RT_ALIGN_SIZE) + sizeof(struct rt_mq_message)) * (max_msgs))
576
577/*
578 * message queue interface
579 */
581 const char *name,
582 void *msgpool,
583 rt_size_t msg_size,
584 rt_size_t pool_size,
585 rt_uint8_t flag);
587#ifdef RT_USING_HEAP
588rt_mq_t rt_mq_create(const char *name,
589 rt_size_t msg_size,
590 rt_size_t max_msgs,
591 rt_uint8_t flag);
593#endif /* RT_USING_HEAP */
594
595rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size);
596rt_err_t rt_mq_send_interruptible(rt_mq_t mq, const void *buffer, rt_size_t size);
597rt_err_t rt_mq_send_killable(rt_mq_t mq, const void *buffer, rt_size_t size);
599 const void *buffer,
600 rt_size_t size,
601 rt_int32_t timeout);
603 const void *buffer,
604 rt_size_t size,
605 rt_int32_t timeout);
607 const void *buffer,
608 rt_size_t size,
609 rt_int32_t timeout);
610rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size);
612 void *buffer,
613 rt_size_t size,
614 rt_int32_t timeout);
616 void *buffer,
617 rt_size_t size,
618 rt_int32_t timeout);
620 void *buffer,
621 rt_size_t size,
622 rt_int32_t timeout);
623rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg);
624
625#ifdef RT_USING_MESSAGEQUEUE_PRIORITY
626rt_err_t rt_mq_send_wait_prio(rt_mq_t mq,
627 const void *buffer,
628 rt_size_t size,
629 rt_int32_t prio,
630 rt_int32_t timeout,
631 int suspend_flag);
632rt_ssize_t rt_mq_recv_prio(rt_mq_t mq,
633 void *buffer,
634 rt_size_t size,
635 rt_int32_t *prio,
636 rt_int32_t timeout,
637 int suspend_flag);
638#endif /* RT_USING_MESSAGEQUEUE_PRIORITY */
639#endif /* RT_USING_MESSAGEQUEUE */
640
642
643/* defunct */
644void rt_thread_defunct_init(void);
647void rt_defunct_execute(void);
648
649/*
650 * spinlock
651 */
652struct rt_spinlock;
653
655void rt_spin_lock(struct rt_spinlock *lock);
656void rt_spin_unlock(struct rt_spinlock *lock);
659
661
662#ifdef RT_USING_DEVICE
667
668/*
669 * device (I/O) system interface
670 */
671rt_device_t rt_device_find(const char *name);
672
674 const char *name,
675 rt_uint16_t flags);
677
678#ifdef RT_USING_HEAP
679rt_device_t rt_device_create(int type, int attach_size);
681#endif /* RT_USING_HEAP */
682
685 rt_err_t (*rx_ind)(rt_device_t dev, rt_size_t size));
688 rt_err_t (*tx_done)(rt_device_t dev, void *buffer));
689
694 rt_off_t pos,
695 void *buffer,
696 rt_size_t size);
698 rt_off_t pos,
699 const void *buffer,
700 rt_size_t size);
701rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg);
702
704#endif /* RT_USING_DEVICE */
705
706/*
707 * interrupt service
708 */
709
710/*
711 * rt_interrupt_enter and rt_interrupt_leave only can be called by BSP
712 */
713void rt_interrupt_enter(void);
714void rt_interrupt_leave(void);
715
719
723struct rt_cpu *rt_cpu_self(void);
724struct rt_cpu *rt_cpu_index(int index);
725
726#ifdef RT_USING_SMP
727
728/*
729 * smp cpus lock service
730 */
731
733void rt_cpus_unlock(rt_base_t level);
734void rt_cpus_lock_status_restore(struct rt_thread *thread);
735
736#ifdef RT_USING_DEBUG
738#else /* !RT_USING_DEBUG */
739 #define rt_cpu_get_id rt_hw_cpu_id
740#endif /* RT_USING_DEBUG */
741
742#else /* !RT_USING_SMP */
743#define rt_cpu_get_id() (0)
744
745#endif /* RT_USING_SMP */
746
747/*
748 * the number of nested interrupts.
749 */
751
752#ifdef RT_USING_HOOK
753void rt_interrupt_enter_sethook(void (*hook)(void));
754void rt_interrupt_leave_sethook(void (*hook)(void));
755#endif /* RT_USING_HOOK */
756
757#ifdef RT_USING_COMPONENTS_INIT
758void rt_components_init(void);
759void rt_components_board_init(void);
760#endif /* RT_USING_COMPONENTS_INIT */
761
766
767/*
768 * general kernel service
769 */
770#ifndef RT_USING_CONSOLE
771#define rt_kprintf(...)
772#define rt_kputs(str)
773#else
774int rt_kprintf(const char *fmt, ...);
775void rt_kputs(const char *str);
776#endif /* RT_USING_CONSOLE */
777
783 long skip, rt_ubase_t *buffer, long buflen);
784
785#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
786rt_device_t rt_console_set_device(const char *name);
787rt_device_t rt_console_get_device(void);
788#ifdef RT_USING_THREADSAFE_PRINTF
789 rt_thread_t rt_console_current_user(void);
790#else
791 rt_inline void *rt_console_current_user(void) { return RT_NULL; }
792#endif /* RT_USING_THREADSAFE_PRINTF */
793#endif /* defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE) */
794
795int __rt_ffs(int value);
796unsigned long __rt_ffsl(unsigned long value);
797unsigned long __rt_clz(unsigned long value);
798
799void rt_show_version(void);
800
801#ifdef RT_DEBUGING_ASSERT
802extern void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line);
803void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t line));
804void rt_assert_handler(const char *ex, const char *func, rt_size_t line);
805
806#define RT_ASSERT(EX) \
807if (!(EX)) \
808{ \
809 rt_assert_handler(#EX, __FUNCTION__, __LINE__); \
810}
811#else
812#define RT_ASSERT(EX) {RT_UNUSED(EX);}
813#endif /* RT_DEBUGING_ASSERT */
814
815#ifdef RT_DEBUGING_CONTEXT
816/* Macro to check current context */
817#define RT_DEBUG_NOT_IN_INTERRUPT \
818do \
819{ \
820 if (rt_interrupt_get_nest() != 0) \
821 { \
822 rt_kprintf("Function[%s] shall not be used in ISR\n", __FUNCTION__); \
823 RT_ASSERT(0) \
824 } \
825} \
826while (0)
827
828/* "In thread context" means:
829 * 1) the scheduler has been started
830 * 2) not in interrupt context.
831 */
832#define RT_DEBUG_IN_THREAD_CONTEXT \
833do \
834{ \
835 if (rt_thread_self() == RT_NULL) \
836 { \
837 rt_kprintf("Function[%s] shall not be used before scheduler start\n", \
838 __FUNCTION__); \
839 RT_ASSERT(0) \
840 } \
841 RT_DEBUG_NOT_IN_INTERRUPT; \
842} \
843while (0)
844
845/* "scheduler available" means:
846 * 1) the scheduler has been started.
847 * 2) not in interrupt context.
848 * 3) scheduler is not locked.
849 */
850#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \
851do \
852{ \
853 if (need_check) \
854 { \
855 if (rt_critical_level() != 0) \
856 { \
857 rt_kprintf("Function[%s]: scheduler is not available\n", \
858 __FUNCTION__); \
859 RT_ASSERT(0) \
860 } \
861 RT_DEBUG_IN_THREAD_CONTEXT; \
862 } \
863} \
864while (0)
865#else
866#define RT_DEBUG_NOT_IN_INTERRUPT
867#define RT_DEBUG_IN_THREAD_CONTEXT
868#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check)
869#endif /* RT_DEBUGING_CONTEXT */
870
872{
873 return rt_thread_self() != RT_NULL && rt_interrupt_get_nest() == 0;
874}
875
876/* is scheduler available */
878{
879 return rt_critical_level() == 0 && rt_in_thread_context();
880}
881
882#ifdef RT_USING_SMP
883/* is thread bond on core */
885{
886 if (thread == RT_NULL)
887 {
888 thread = rt_thread_self();
889 }
890 return !thread || RT_SCHED_CTX(thread).bind_cpu != RT_CPUS_NR;
891}
892
893#else
894#define rt_sched_thread_is_binding(thread) (RT_TRUE)
895#endif
896
898
899#ifdef __cplusplus
900}
901#endif
902
903#endif /* __RT_THREAD_H__ */
rt_base_t rt_cpus_lock(void)
This function will lock all cpus's scheduler and disable local irq.
void rt_cpus_unlock(rt_base_t level)
This function will restore all cpus's scheduler and restore local irq.
void rt_cpus_lock_status_restore(struct rt_thread *thread)
rt_err_t rt_timer_detach(rt_timer_t timer)
This function will detach a timer from timer management.
rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
This function will get or set some options of the timer
void rt_timer_exit_sethook(void(*hook)(struct rt_timer *timer))
void rt_tick_increase(void)
This function will notify kernel there is one tick passed. Normally, this function is invoked by cloc...
struct rt_timer * rt_timer_t
void rt_timer_check(void)
This function will check timer list, if a timeout event happens, the corresponding timeout function w...
rt_err_t rt_timer_start(rt_timer_t timer)
This function will start the timer
rt_tick_t rt_timer_next_timeout_tick(void)
This function will return the next timeout tick in the system.
void rt_timer_enter_sethook(void(*hook)(struct rt_timer *timer))
void rt_tick_increase_tick(rt_tick_t tick)
This function will notify kernel there is n tick passed. Normally, this function is invoked by clock ...
void rt_timer_init(rt_timer_t timer, const char *name, void(*timeout)(void *parameter), void *parameter, rt_tick_t time, rt_uint8_t flag)
This function will initialize a timer normally this function is used to initialize a static timer obj...
rt_tick_t rt_tick_get(void)
This function will return current tick from operating system startup.
定义 clock.c:69
rt_weak rt_tick_t rt_tick_get_millisecond(void)
This function will return the passed millisecond from boot.
void rt_tick_set(rt_tick_t tick)
This function will set current tick.
定义 clock.c:81
rt_timer_t rt_timer_create(const char *name, void(*timeout)(void *parameter), void *parameter, rt_tick_t time, rt_uint8_t flag)
This function will create a timer
void rt_system_timer_init(void)
This function will initialize system timer
rt_tick_t rt_tick_from_millisecond(rt_int32_t ms)
This function will calculate the tick from millisecond.
rt_err_t rt_timer_stop(rt_timer_t timer)
This function will stop the timer
void rt_tick_sethook(void(*hook)(void))
void rt_system_timer_thread_init(void)
This function will initialize system timer thread
rt_err_t rt_timer_delete(rt_timer_t timer)
This function will delete a timer and release timer memory
rt_err_t rt_device_init(rt_device_t dev)
rt_err_t rt_device_set_rx_indicate(rt_device_t dev, rt_err_t(*rx_ind)(rt_device_t dev, rt_size_t size))
rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg)
rt_ssize_t rt_device_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
rt_ssize_t rt_device_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
rt_device_t rt_device_create(int type, int attach_size)
void rt_device_destroy(rt_device_t device)
rt_err_t rt_device_unregister(rt_device_t dev)
rt_device_t rt_device_find(const char *name)
struct rt_device * rt_device_t
rt_err_t rt_device_close(rt_device_t dev)
rt_err_t rt_device_register(rt_device_t dev, const char *name, rt_uint16_t flags)
rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
rt_err_t rt_device_set_tx_complete(rt_device_t dev, rt_err_t(*tx_done)(rt_device_t dev, void *buffer))
void rt_realloc_set_exit_hook(void(*hook)(void **ptr, rt_size_t size))
This function will set a hook function, which will be invoked when a memory block is allocated from h...
void rt_free_sethook(void(*hook)(void **ptr))
This function will set a hook function, which will be invoked when a memory block is released to heap...
void rt_realloc_set_entry_hook(void(*hook)(void **ptr, rt_size_t size))
This function will set a hook function, which will be invoked when a memory block is allocated from h...
void rt_malloc_sethook(void(*hook)(void **ptr, rt_size_t size))
This function will set a hook function, which will be invoked when a memory block is allocated from h...
void rt_thread_defunct_enqueue(rt_thread_t thread)
Enqueue a thread to defunct queue.
void rt_defunct_execute(void)
This function will perform system background job when system idle.
rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock)
This function will disable the local interrupt and then lock the spinlock, will lock the thread sched...
rt_thread_t rt_thread_defunct_dequeue(void)
Dequeue a thread from defunct queue.
rt_err_t rt_susp_list_resume_all_irq(rt_list_t *susp_list, rt_err_t thread_error, struct rt_spinlock *lock)
This function will resume all suspended threads in the IPC object list, including the suspended list ...
定义 ipc.c:204
void rt_thread_defunct_init(void)
rt_err_t rt_thread_suspend_to_list(rt_thread_t thread, rt_list_t *susp_list, int ipc_flags, int suspend_flag)
This function will suspend the specified thread and change it to suspend state.
rt_err_t rt_susp_list_resume_all(rt_list_t *susp_list, rt_err_t thread_error)
This function will resume all suspended threads in the IPC object list, including the suspended list ...
定义 ipc.c:165
void rt_susp_list_print(rt_list_t *list)
Print thread on suspend list to system console
定义 ipc.c:290
void rt_spin_lock(struct rt_spinlock *lock)
This function will lock the spinlock, will lock the thread scheduler.
void rt_spin_lock_init(struct rt_spinlock *lock)
Initialize a static spinlock object.
void rt_spin_unlock(struct rt_spinlock *lock)
This function will unlock the spinlock, will unlock the thread scheduler.
struct rt_thread * rt_susp_list_dequeue(rt_list_t *susp_list, rt_err_t thread_error)
Dequeue a thread from suspended list and set it to ready. The 2 are taken as an atomic operation,...
定义 ipc.c:105
rt_err_t rt_susp_list_enqueue(rt_list_t *susp_list, rt_thread_t thread, int ipc_flags)
Add a thread to the suspend list
定义 ipc.c:241
void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level)
This function will unlock the spinlock and then restore current cpu interrupt status,...
void rt_interrupt_enter(void)
This function will be invoked by BSP, when enter interrupt service routine
定义 irq.c:100
rt_uint8_t rt_interrupt_get_nest(void)
This function will return the nest of interrupt.
定义 irq.c:136
void rt_interrupt_leave(void)
This function will be invoked by BSP, when leave interrupt service routine
定义 irq.c:117
void rt_object_delete(rt_object_t object)
This function will delete an object and release object memory.
void rt_object_init(struct rt_object *object, enum rt_object_class_type type, const char *name)
This function will initialize an object and add it to object system management.
rt_bool_t rt_object_is_systemobject(rt_object_t object)
This function will judge the object is system object or not.
void rt_object_detach_sethook(void(*hook)(struct rt_object *object))
rt_object_class_type
rt_err_t rt_object_get_name(rt_object_t object, char *name, rt_uint8_t name_size)
This function will return the name of the specified object container
rt_err_t rt_custom_object_destroy(rt_object_t obj)
rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
This function will allocate an object from object system.
void rt_object_take_sethook(void(*hook)(struct rt_object *object))
rt_object_t rt_object_find(const char *name, rt_uint8_t type)
This function will find specified name object from object container.
rt_object_t rt_custom_object_create(const char *name, void *data, rt_err_t(*data_destroy)(void *))
void rt_object_attach_sethook(void(*hook)(struct rt_object *object))
struct rt_object_information * rt_object_get_information(enum rt_object_class_type type)
This function will return the specified type of object information.
rt_uint8_t rt_object_get_type(rt_object_t object)
This function will return the type of object without RT_Object_Class_Static flag.
struct rt_object * rt_object_t
int rt_object_get_length(enum rt_object_class_type type)
This function will return the length of object list in object container.
rt_err_t rt_object_for_each(rt_uint8_t type, rt_object_iter_t iter, void *data)
This function will iterate through each object from object container.
int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
This function will copy the object pointer of the specified type, with the maximum size specified by ...
void rt_object_trytake_sethook(void(*hook)(struct rt_object *object))
rt_err_t(* rt_object_iter_t)(rt_object_t object, void *data)
void rt_object_put_sethook(void(*hook)(struct rt_object *object))
void rt_object_detach(rt_object_t object)
This function will detach a static object from object system, and the memory of static object is not ...
#define RT_OBJECT_HOOKLIST_DECLARE(handler_type, name)
#define rt_kputs(str)
void rt_show_version(void)
This function will show the version of rt-thread rtos
rt_inline rt_bool_t rt_scheduler_is_available(void)
rt_inline rt_bool_t rt_in_thread_context(void)
#define rt_kprintf(...)
rt_weak rt_err_t rt_backtrace_to_buffer(rt_thread_t thread, struct rt_hw_backtrace_frame *frame, long skip, rt_ubase_t *buffer, long buflen)
Print backtrace from frame to the given buffer
unsigned long __rt_ffsl(unsigned long value)
unsigned long __rt_clz(unsigned long value)
rt_weak rt_err_t rt_backtrace_formatted_print(rt_ubase_t *buffer, long buflen)
Print backtrace from buffer to system console
rt_weak rt_err_t rt_backtrace_frame(rt_thread_t thread, struct rt_hw_backtrace_frame *frame)
Print backtrace from frame to system console device
#define rt_sched_thread_is_binding(thread)
int __rt_ffs(int value)
This function finds the first bit set (beginning with the least significant bit) in value and return ...
rt_weak rt_err_t rt_backtrace(void)
Print backtrace of current thread to system console device
rt_err_t rt_backtrace_thread(rt_thread_t thread)
Print backtrace of a thread to system console device
void rt_smem_free(void *rmem)
This function will release the previously allocated memory block by rt_mem_alloc. The released memory...
定义 mem.c:497
rt_err_t rt_mp_init(struct rt_mempool *mp, const char *name, void *start, rt_size_t size, rt_size_t block_size)
This function will initialize a memory pool object, normally which is used for static object.
void * rt_malloc_align(rt_size_t size, rt_size_t align)
This function allocates a memory block, which address is aligned to the specified alignment size.
void rt_mp_alloc_sethook(void(*hook)(struct rt_mempool *mp, void *block))
rt_mem_t rt_smem_t
void * rt_mp_alloc(rt_mp_t mp, rt_int32_t time)
This function will allocate a block from memory pool.
void rt_mp_free(void *block)
This function will release a memory block.
rt_err_t rt_mp_detach(struct rt_mempool *mp)
This function will detach a memory pool from system object management.
void rt_memory_info(rt_size_t *total, rt_size_t *used, rt_size_t *max_used)
This function will caculate the total memory, the used memory, and the max used memory.
void rt_free(void *ptr)
This function will release the previously allocated memory block by rt_malloc. The released memory bl...
void * rt_malloc(rt_size_t size)
Allocate a block of memory with a minimum of 'size' bytes.
void * rt_smem_alloc(rt_smem_t m, rt_size_t size)
Allocate a block of memory with a minimum of 'size' bytes.
定义 mem.c:271
void * rt_calloc(rt_size_t count, rt_size_t size)
This function will contiguously allocate enough space for count objects that are size bytes of memory...
void * rt_realloc(void *ptr, rt_size_t newsize)
This function will change the size of previously allocated memory block.
void * rt_smem_realloc(rt_smem_t m, void *rmem, rt_size_t newsize)
This function will change the size of previously allocated memory block.
定义 mem.c:403
rt_mp_t rt_mp_create(const char *name, rt_size_t block_count, rt_size_t block_size)
This function will create a mempool object and allocate the memory pool from heap.
void rt_free_align(void *ptr)
This function release the memory block, which is allocated by rt_malloc_align function and address is...
struct rt_mempool * rt_mp_t
rt_err_t rt_mp_delete(rt_mp_t mp)
This function will delete a memory pool and release the object memory.
rt_smem_t rt_smem_init(const char *name, void *begin_addr, rt_size_t size)
This function will initialize small memory management algorithm.
定义 mem.c:170
rt_err_t rt_smem_detach(rt_smem_t m)
This function will remove a small mem from the system.
定义 mem.c:244
void rt_system_heap_init_generic(void *begin_addr, void *end_addr)
This function will do the generic system heap initialization.
void rt_system_heap_init(void *begin_addr, void *end_addr)
This function will init system heap. User can override this API to complete other works,...
void rt_mp_free_sethook(void(*hook)(struct rt_mempool *mp, void *block))
rt_err_t rt_thread_startup(rt_thread_t thread)
This function will start a thread and put it to system ready queue.
rt_err_t rt_thread_close(rt_thread_t thread)
This function will close a thread. The thread object will be removed from thread queue and detached/d...
rt_err_t rt_thread_get_name(rt_thread_t thread, char *name, rt_uint8_t name_size)
This function will return the name of the specified thread
void rt_scheduler_sethook(void(*hook)(rt_thread_t from, rt_thread_t to))
void rt_scheduler_ipi_handler(int vector, void *param)
This function will handle IPI interrupt and do a scheduling in system.
void rt_exit_critical_safe(rt_base_t critical_level)
rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
This function will let current thread delay until (*tick + inc_tick).
rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
This function will control thread behaviors according to control command.
void rt_exit_critical(void)
This function will unlock the thread scheduler.
void rt_scheduler_switch_sethook(void(*hook)(struct rt_thread *tid))
rt_err_t rt_thread_mdelay(rt_int32_t ms)
This function will let current thread delay for some milliseconds.
rt_err_t rt_thread_detach(rt_thread_t thread)
This function will detach a thread. The thread object will be removed from thread queue and detached/...
rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag)
This function will suspend the specified thread and change it to suspend state.
rt_err_t rt_thread_yield(void)
This function will let current thread yield processor, and scheduler will choose the highest thread t...
void rt_system_scheduler_init(void)
This function will initialize the system scheduler.
rt_thread_t rt_thread_self(void)
This function will return self thread object.
rt_err_t rt_thread_delay(rt_tick_t tick)
This function will let current thread delay for some ticks.
rt_err_t rt_thread_delete(rt_thread_t thread)
This function will delete a thread. The thread object will be removed from thread queue and deleted f...
void(* rt_thread_inited_hookproto_t)(rt_thread_t thread)
Sets a hook function when a thread is initialized.
rt_thread_t rt_thread_find(char *name)
This function will find the specified thread.
void rt_thread_suspend_sethook(void(*hook)(rt_thread_t thread))
void rt_system_scheduler_start(void)
This function will startup the scheduler. It will select one thread with the highest priority level,...
rt_err_t rt_thread_resume(rt_thread_t thread)
This function will resume a thread and put it to system ready queue.
rt_err_t rt_thread_suspend(rt_thread_t thread)
rt_err_t rt_thread_idle_sethook(void(*hook)(void))
void rt_scheduler_do_irq_switch(void *context)
This function checks whether a scheduling is needed after an IRQ context switching....
rt_base_t rt_enter_critical(void)
This function will lock the thread scheduler.
rt_thread_t rt_thread_create(const char *name, void(*entry)(void *parameter), void *parameter, rt_uint32_t stack_size, rt_uint8_t priority, rt_uint32_t tick)
This function will create a thread object and allocate thread object memory. and stack.
rt_err_t rt_thread_init(struct rt_thread *thread, const char *name, void(*entry)(void *parameter), void *parameter, void *stack_start, rt_uint32_t stack_size, rt_uint8_t priority, rt_uint32_t tick)
This function will initialize a thread. It's used to initialize a static thread object.
struct rt_thread * rt_thread_t
rt_thread_t rt_thread_idle_gethandler(void)
This function will get the handler of the idle thread.
定义 idle.c:214
void rt_thread_resume_sethook(void(*hook)(rt_thread_t thread))
void rt_thread_idle_init(void)
This function will initialize idle thread, then start it.
定义 idle.c:171
struct rt_interrupt_context * rt_interrupt_context_t
void rt_schedule(void)
This function will perform one scheduling. It will select one thread with the highest priority level ...
rt_uint16_t rt_critical_level(void)
Get the scheduler lock level.
rt_err_t rt_thread_idle_delhook(void(*hook)(void))
delete the idle hook on hook list.
定义 idle.c:101
rt_err_t rt_event_recv_interruptible(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_int32_t timeout, rt_uint32_t *recved)
定义 ipc.c:2232
rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg)
This function will set some extra attributions of an event object.
定义 ipc.c:2265
rt_event_t rt_event_create(const char *name, rt_uint8_t flag)
Creating an event object.
定义 ipc.c:1878
rt_err_t rt_event_detach(rt_event_t event)
This function will detach a static event object.
定义 ipc.c:1828
rt_err_t rt_event_recv(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_int32_t timeout, rt_uint32_t *recved)
定义 ipc.c:2222
rt_err_t rt_event_delete(rt_event_t event)
This function will delete an event object and release the memory space.
定义 ipc.c:1924
rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
This function will send an event to the event object. If there is a thread suspended on the event,...
定义 ipc.c:1964
rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag)
The function will initialize a static event object.
定义 ipc.c:1786
rt_err_t rt_event_recv_killable(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_int32_t timeout, rt_uint32_t *recved)
定义 ipc.c:2242
struct rt_event * rt_event_t
rt_err_t rt_mb_recv_killable(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
定义 ipc.c:2986
rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg)
This function will set some extra attributions of a mailbox object.
定义 ipc.c:3006
rt_err_t rt_mb_send_wait_killable(rt_mailbox_t mb, rt_ubase_t value, rt_int32_t timeout)
定义 ipc.c:2710
rt_err_t rt_mb_detach(rt_mailbox_t mb)
This function will detach a static mailbox object.
定义 ipc.c:2395
rt_err_t rt_mb_send_killable(rt_mailbox_t mb, rt_ubase_t value)
定义 ipc.c:2746
rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
定义 ipc.c:2974
rt_err_t rt_mb_delete(rt_mailbox_t mb)
This function will delete a mailbox object and release the memory space.
定义 ipc.c:2510
rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
Creating a mailbox object.
定义 ipc.c:2450
rt_err_t rt_mb_recv_interruptible(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
定义 ipc.c:2980
struct rt_mailbox * rt_mailbox_t
rt_err_t rt_mb_send_interruptible(rt_mailbox_t mb, rt_ubase_t value)
定义 ipc.c:2740
rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value)
This function will send an urgent mail to the mailbox object.
定义 ipc.c:2768
rt_err_t rt_mb_init(rt_mailbox_t mb, const char *name, void *msgpool, rt_size_t size, rt_uint8_t flag)
Initialize a static mailbox object.
定义 ipc.c:2343
rt_err_t rt_mb_send(rt_mailbox_t mb, rt_ubase_t value)
This function will send an mail to the mailbox object. If there is a thread suspended on the mailbox,...
定义 ipc.c:2734
rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_ubase_t value, rt_int32_t timeout)
定义 ipc.c:2694
rt_err_t rt_mb_send_wait_interruptible(rt_mailbox_t mb, rt_ubase_t value, rt_int32_t timeout)
定义 ipc.c:2702
rt_err_t rt_mq_send_wait(rt_mq_t mq, const void *buffer, rt_size_t size, rt_int32_t timeout)
定义 ipc.c:3568
rt_err_t rt_mq_detach(rt_mq_t mq)
This function will detach a static messagequeue object.
定义 ipc.c:3173
rt_mq_t rt_mq_create(const char *name, rt_size_t msg_size, rt_size_t max_msgs, rt_uint8_t flag)
Creating a messagequeue object.
定义 ipc.c:3229
rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg)
This function will set some extra attributions of a messagequeue object.
定义 ipc.c:3980
rt_err_t rt_mq_send_wait_killable(rt_mq_t mq, const void *buffer, rt_size_t size, rt_int32_t timeout)
定义 ipc.c:3586
struct rt_messagequeue * rt_mq_t
rt_ssize_t rt_mq_recv_killable(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout)
定义 ipc.c:3938
rt_err_t rt_mq_send_killable(rt_mq_t mq, const void *buffer, rt_size_t size)
定义 ipc.c:3628
rt_err_t rt_mq_send_interruptible(rt_mq_t mq, const void *buffer, rt_size_t size)
定义 ipc.c:3622
rt_ssize_t rt_mq_recv_interruptible(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout)
定义 ipc.c:3929
rt_err_t rt_mq_init(rt_mq_t mq, const char *name, void *msgpool, rt_size_t msg_size, rt_size_t pool_size, rt_uint8_t flag)
Initialize a static messagequeue object.
定义 ipc.c:3092
rt_err_t rt_mq_send(rt_mq_t mq, const void *buffer, rt_size_t size)
This function will send a message to the messagequeue object. If there is a thread suspended on the m...
定义 ipc.c:3616
rt_err_t rt_mq_send_wait_interruptible(rt_mq_t mq, const void *buffer, rt_size_t size, rt_int32_t timeout)
定义 ipc.c:3577
rt_err_t rt_mq_delete(rt_mq_t mq)
This function will delete a messagequeue object and release the memory.
定义 ipc.c:3315
rt_ssize_t rt_mq_recv(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout)
定义 ipc.c:3920
rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size)
This function will send an urgent message to the messagequeue object.
定义 ipc.c:3651
rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg)
This function will set some extra attributions of a mutex object.
定义 ipc.c:1733
rt_err_t rt_mutex_take_interruptible(rt_mutex_t mutex, rt_int32_t time)
定义 ipc.c:1543
rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag)
This function will create a mutex object.
定义 ipc.c:1233
rt_inline rt_ubase_t rt_mutex_get_hold(rt_mutex_t mutex)
rt_err_t rt_mutex_take_killable(rt_mutex_t mutex, rt_int32_t time)
定义 ipc.c:1549
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
定义 ipc.c:1537
rt_err_t rt_mutex_detach(rt_mutex_t mutex)
This function will detach a static mutex object.
定义 ipc.c:1054
rt_uint8_t rt_mutex_setprioceiling(rt_mutex_t mutex, rt_uint8_t priority)
set the prioceiling attribute of the mutex.
定义 ipc.c:1151
rt_err_t rt_mutex_delete(rt_mutex_t mutex)
This function will delete a mutex object and release this memory space.
定义 ipc.c:1283
void rt_mutex_drop_thread(rt_mutex_t mutex, rt_thread_t thread)
drop a thread from the suspend list of mutex
定义 ipc.c:1078
rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag)
Initialize a static mutex object.
定义 ipc.c:1007
rt_inline rt_thread_t rt_mutex_get_owner(rt_mutex_t mutex)
rt_err_t rt_mutex_release(rt_mutex_t mutex)
This function will release a mutex. If there is thread suspended on the mutex, the thread will be res...
定义 ipc.c:1589
struct rt_mutex * rt_mutex_t
rt_err_t rt_mutex_trytake(rt_mutex_t mutex)
This function will try to take a mutex, if the mutex is unavailable, the thread returns immediately.
定义 ipc.c:1570
rt_uint8_t rt_mutex_getprioceiling(rt_mutex_t mutex)
set the prioceiling attribute of the mutex.
定义 ipc.c:1194
rt_err_t rt_sem_init(rt_sem_t sem, const char *name, rt_uint32_t value, rt_uint8_t flag)
This function will initialize a static semaphore object.
定义 ipc.c:376
rt_err_t rt_sem_delete(rt_sem_t sem)
This function will delete a semaphore object and release the memory space.
定义 ipc.c:506
rt_err_t rt_sem_take_killable(rt_sem_t sem, rt_int32_t time)
定义 ipc.c:656
rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg)
This function will set some extra attributions of a semaphore object.
定义 ipc.c:759
rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
Creating a semaphore object.
定义 ipc.c:467
rt_err_t rt_sem_take_interruptible(rt_sem_t sem, rt_int32_t time)
定义 ipc.c:650
rt_err_t rt_sem_detach(rt_sem_t sem)
This function will detach a static semaphore object.
定义 ipc.c:413
rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
定义 ipc.c:644
struct rt_semaphore * rt_sem_t
rt_err_t rt_sem_release(rt_sem_t sem)
This function will release a semaphore. If there is thread suspended on the semaphore,...
定义 ipc.c:695
rt_err_t rt_sem_trytake(rt_sem_t sem)
This function will try to take a semaphore, if the semaphore is unavailable, the thread returns immed...
定义 ipc.c:676
#define RT_SCHED_CTX(thread)
void rt_interrupt_context_push(rt_interrupt_context_t this_ctx)
void rt_interrupt_enter_sethook(void(*hook)(void))
void rt_interrupt_leave_sethook(void(*hook)(void))
struct rt_cpu * rt_cpu_index(int index)
This fucntion will return the cpu object corresponding to index.
struct rt_cpu * rt_cpu_self(void)
This fucntion will return current cpu object.
void rt_interrupt_context_pop(void)
#define rt_cpu_get_id()
void * rt_interrupt_context_get(void)
rt_base_t rt_ssize_t
rt_int32_t rt_base_t
rt_base_t rt_off_t
int rt_bool_t
rt_base_t rt_err_t
unsigned char rt_uint8_t
unsigned short rt_uint16_t
rt_uint32_t rt_tick_t
rt_ubase_t rt_size_t
struct rt_list_node rt_list_t
unsigned int rt_uint32_t
rt_uint32_t rt_ubase_t
#define RT_NULL
signed int rt_int32_t
rt_ssize_t length
struct rt_mq_message * next
struct rt_thread * owner
rt_uint8_t hold
enum rt_object_class_type type
rt_ubase_t lock