Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76519099
rt-thread
提交
9b445357
R
rt-thread
项目概览
2301_76519099
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
3
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9b445357
编写于
1月 26, 2022
作者:
G
guozhanxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add RT_DEBUG_SCHEDULER_AVAILABLE check
上级
e665bacf
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
96 addition
and
18 deletion
+96
-18
components/dfs/filesystems/devfs/devfs.c
components/dfs/filesystems/devfs/devfs.c
+11
-1
components/drivers/ipc/completion.c
components/drivers/ipc/completion.c
+6
-0
components/drivers/ipc/dataqueue.c
components/drivers/ipc/dataqueue.c
+12
-6
components/drivers/ipc/waitqueue.c
components/drivers/ipc/waitqueue.c
+1
-1
include/rtdebug.h
include/rtdebug.h
+23
-0
src/ipc.c
src/ipc.c
+43
-10
未找到文件。
components/dfs/filesystems/devfs/devfs.c
浏览文件 @
9b445357
...
...
@@ -144,11 +144,15 @@ int dfs_device_fs_open(struct dfs_fd *file)
{
count
++
;
}
rt_exit_critical
();
root_dirent
=
(
struct
device_dirent
*
)
rt_malloc
(
sizeof
(
struct
device_dirent
)
+
count
*
sizeof
(
rt_device_t
));
if
(
root_dirent
!=
RT_NULL
)
{
/* lock scheduler */
rt_enter_critical
();
root_dirent
->
devices
=
(
rt_device_t
*
)(
root_dirent
+
1
);
root_dirent
->
read_index
=
0
;
root_dirent
->
device_count
=
count
;
...
...
@@ -156,12 +160,18 @@ int dfs_device_fs_open(struct dfs_fd *file)
/* get all device node */
for
(
node
=
information
->
object_list
.
next
;
node
!=
&
(
information
->
object_list
);
node
=
node
->
next
)
{
/* avoid memory write through */
if
(
count
==
root_dirent
->
device_count
)
{
rt_kprintf
(
"warning: There are newly added devices that are not displayed!"
);
break
;
}
object
=
rt_list_entry
(
node
,
struct
rt_object
,
list
);
root_dirent
->
devices
[
count
]
=
(
rt_device_t
)
object
;
count
++
;
}
rt_exit_critical
();
}
rt_exit_critical
();
/* set data */
file
->
data
=
root_dirent
;
...
...
components/drivers/ipc/completion.c
浏览文件 @
9b445357
...
...
@@ -57,6 +57,12 @@ rt_err_t rt_completion_wait(struct rt_completion *completion,
rt_thread_t
thread
;
RT_ASSERT
(
completion
!=
RT_NULL
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
result
=
RT_EOK
;
thread
=
rt_thread_self
();
...
...
components/drivers/ipc/dataqueue.c
浏览文件 @
9b445357
...
...
@@ -98,6 +98,12 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
RT_ASSERT
(
queue
!=
RT_NULL
);
RT_ASSERT
(
queue
->
magic
==
DATAQUEUE_MAGIC
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
result
=
RT_EOK
;
thread
=
rt_thread_self
();
...
...
@@ -112,9 +118,6 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
goto
__exit
;
}
/* current context checking */
RT_DEBUG_NOT_IN_INTERRUPT
;
/* reset thread error number */
thread
->
error
=
RT_EOK
;
...
...
@@ -217,6 +220,12 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
RT_ASSERT
(
data_ptr
!=
RT_NULL
);
RT_ASSERT
(
size
!=
RT_NULL
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
result
=
RT_EOK
;
thread
=
rt_thread_self
();
...
...
@@ -230,9 +239,6 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
goto
__exit
;
}
/* current context checking */
RT_DEBUG_NOT_IN_INTERRUPT
;
/* reset thread error number */
thread
->
error
=
RT_EOK
;
...
...
components/drivers/ipc/waitqueue.c
浏览文件 @
9b445357
...
...
@@ -129,7 +129,7 @@ int rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec)
rt_base_t
level
;
/* current context checking */
RT_DEBUG_
NOT_IN_INTERRUPT
;
RT_DEBUG_
SCHEDULER_AVAILABLE
;
tick
=
rt_tick_from_millisecond
(
msec
);
...
...
include/rtdebug.h
浏览文件 @
9b445357
...
...
@@ -110,9 +110,31 @@ do \
rt_hw_interrupt_enable(level); \
} \
while (0)
/* "scheduler available" means:
* 1) the scheduler has been started.
* 2) not in interrupt context.
* 3) scheduler is not locked.
*/
#define RT_DEBUG_SCHEDULER_AVAILABLE \
do \
{ \
rt_base_t level; \
level = rt_hw_interrupt_disable(); \
if (rt_critical_level() != 0) \
{ \
rt_kprintf("Function[%s]: scheduler is not available\n", \
__FUNCTION__); \
RT_ASSERT(0) \
} \
RT_DEBUG_IN_THREAD_CONTEXT; \
rt_hw_interrupt_enable(level); \
} \
while (0)
#else
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
#define RT_DEBUG_SCHEDULER_AVAILABLE
#endif
#else
/* RT_DEBUG */
...
...
@@ -121,6 +143,7 @@ while (0)
#define RT_DEBUG_LOG(type, message)
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
#define RT_DEBUG_SCHEDULER_AVAILABLE
#endif
/* RT_DEBUG */
...
...
src/ipc.c
浏览文件 @
9b445357
...
...
@@ -484,6 +484,11 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
/* parameter check */
RT_ASSERT
(
sem
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
sem
->
parent
.
parent
)
==
RT_Object_Class_Semaphore
);
/* current context checking */
if
(
time
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
RT_OBJECT_HOOK_CALL
(
rt_object_trytake_hook
,
(
&
(
sem
->
parent
.
parent
)));
...
...
@@ -514,9 +519,6 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
}
else
{
/* current context checking */
RT_DEBUG_IN_THREAD_CONTEXT
;
/* semaphore is unavailable, push to suspend list */
/* get current thread */
thread
=
rt_thread_self
();
...
...
@@ -914,6 +916,12 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
/* this function must not be used in interrupt even if time = 0 */
RT_DEBUG_IN_THREAD_CONTEXT
;
/* current context checking */
if
(
time
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
/* parameter check */
RT_ASSERT
(
mutex
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mutex
->
parent
.
parent
)
==
RT_Object_Class_Mutex
);
...
...
@@ -1566,12 +1574,18 @@ rt_err_t rt_event_recv(rt_event_t event,
register
rt_ubase_t
level
;
register
rt_base_t
status
;
RT_DEBUG_IN_THREAD_CONTEXT
;
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
event
->
parent
.
parent
)
==
RT_Object_Class_Event
);
/* current context checking */
RT_DEBUG_IN_THREAD_CONTEXT
;
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
if
(
set
==
0
)
return
-
RT_ERROR
;
...
...
@@ -1993,6 +2007,12 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
RT_ASSERT
(
mb
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mb
->
parent
.
parent
)
==
RT_Object_Class_MailBox
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
/* initialize delta tick */
tick_delta
=
0
;
/* get current thread */
...
...
@@ -2025,7 +2045,6 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
return
-
RT_EFULL
;
}
RT_DEBUG_IN_THREAD_CONTEXT
;
/* suspend current thread */
_ipc_list_suspend
(
&
(
mb
->
suspend_sender_thread
),
thread
,
...
...
@@ -2236,6 +2255,12 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
RT_ASSERT
(
mb
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mb
->
parent
.
parent
)
==
RT_Object_Class_MailBox
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
/* initialize delta tick */
tick_delta
=
0
;
/* get current thread */
...
...
@@ -2271,7 +2296,6 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
return
-
RT_ETIMEOUT
;
}
RT_DEBUG_IN_THREAD_CONTEXT
;
/* suspend current thread */
_ipc_list_suspend
(
&
(
mb
->
parent
.
suspend_thread
),
thread
,
...
...
@@ -2744,6 +2768,12 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
RT_ASSERT
(
buffer
!=
RT_NULL
);
RT_ASSERT
(
size
!=
0
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
/* greater than one message size */
if
(
size
>
mq
->
msg_size
)
return
-
RT_ERROR
;
...
...
@@ -2784,7 +2814,6 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
return
-
RT_EFULL
;
}
RT_DEBUG_IN_THREAD_CONTEXT
;
/* suspend current thread */
_ipc_list_suspend
(
&
(
mq
->
suspend_sender_thread
),
thread
,
...
...
@@ -3054,6 +3083,12 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
RT_ASSERT
(
buffer
!=
RT_NULL
);
RT_ASSERT
(
size
!=
0
);
/* current context checking */
if
(
timeout
!=
0
)
{
RT_DEBUG_SCHEDULER_AVAILABLE
;
}
/* initialize delta tick */
tick_delta
=
0
;
/* get current thread */
...
...
@@ -3074,8 +3109,6 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
/* message queue is empty */
while
(
mq
->
entry
==
0
)
{
RT_DEBUG_IN_THREAD_CONTEXT
;
/* reset error number in thread */
thread
->
error
=
RT_EOK
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录