summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2022-01-26 16:02:24 +0800
committerguozhanxin <[email protected]>2022-01-26 16:03:31 +0800
commit9b44535740b7e1deda584e8c7397b40113fa43f0 (patch)
tree7f318dcfbf7a8f01da544e909653a5601e4d13a6 /components
parente665bacf89c5901244cd43e195a7ae039b3c0463 (diff)
add RT_DEBUG_SCHEDULER_AVAILABLE check
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/devfs/devfs.c12
-rw-r--r--components/drivers/ipc/completion.c6
-rw-r--r--components/drivers/ipc/dataqueue.c18
-rw-r--r--components/drivers/ipc/waitqueue.c2
4 files changed, 30 insertions, 8 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c
index d60f7ddc9b..8e58fb9f53 100644
--- a/components/dfs/filesystems/devfs/devfs.c
+++ b/components/dfs/filesystems/devfs/devfs.c
@@ -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;
diff --git a/components/drivers/ipc/completion.c b/components/drivers/ipc/completion.c
index f13718f9b3..4983327e1d 100644
--- a/components/drivers/ipc/completion.c
+++ b/components/drivers/ipc/completion.c
@@ -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();
diff --git a/components/drivers/ipc/dataqueue.c b/components/drivers/ipc/dataqueue.c
index 4e52662c44..fc77f83922 100644
--- a/components/drivers/ipc/dataqueue.c
+++ b/components/drivers/ipc/dataqueue.c
@@ -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;
diff --git a/components/drivers/ipc/waitqueue.c b/components/drivers/ipc/waitqueue.c
index 6a26604617..f65b34cdcf 100644
--- a/components/drivers/ipc/waitqueue.c
+++ b/components/drivers/ipc/waitqueue.c
@@ -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);