Skip to content

Commit 4562ae1

Browse files
authored
[kernel] Revert modifications to the semaphore (#5682)
1 parent aa80ba2 commit 4562ae1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/ipc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,6 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
485485
RT_ASSERT(sem != RT_NULL);
486486
RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore);
487487

488-
/* current context checking */
489-
RT_DEBUG_SCHEDULER_AVAILABLE(time != 0);
490-
491488
RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(sem->parent.parent)));
492489

493490
/* disable interrupt */
@@ -517,6 +514,9 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
517514
}
518515
else
519516
{
517+
/* current context checking */
518+
RT_DEBUG_SCHEDULER_AVAILABLE(RT_TRUE);
519+
520520
/* semaphore is unavailable, push to suspend list */
521521
/* get current thread */
522522
thread = rt_thread_self();

src/memheap.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
203203
free_size = 0;
204204

205205
/* lock memheap */
206-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
206+
if (heap->locked == RT_FALSE)
207207
{
208208
result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER);
209209
if (result != RT_EOK)
@@ -316,7 +316,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
316316
rt_memcpy(header_ptr->owner_thread_name, "NONE", sizeof(header_ptr->owner_thread_name));
317317
#endif /* RT_USING_MEMTRACE */
318318

319-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
319+
if (heap->locked == RT_FALSE)
320320
{
321321
/* release lock */
322322
rt_sem_release(&(heap->lock));
@@ -332,7 +332,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
332332
return (void *)((rt_uint8_t *)header_ptr + RT_MEMHEAP_SIZE);
333333
}
334334

335-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
335+
if (heap->locked == RT_FALSE)
336336
{
337337
/* release lock */
338338
rt_sem_release(&(heap->lock));
@@ -394,7 +394,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
394394
void *new_ptr;
395395
struct rt_memheap_item *next_ptr;
396396

397-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
397+
if (heap->locked == RT_FALSE)
398398
{
399399
/* lock memheap */
400400
result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER);
@@ -475,7 +475,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
475475
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x",
476476
next_ptr->next_free,
477477
next_ptr->prev_free));
478-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
478+
if (heap->locked == RT_FALSE)
479479
{
480480
/* release lock */
481481
rt_sem_release(&(heap->lock));
@@ -485,7 +485,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
485485
}
486486
}
487487

488-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
488+
if (heap->locked == RT_FALSE)
489489
{
490490
/* release lock */
491491
rt_sem_release(&(heap->lock));
@@ -506,7 +506,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
506506
if (newsize + RT_MEMHEAP_SIZE + RT_MEMHEAP_MINIALLOC >= oldsize)
507507
return ptr;
508508

509-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
509+
if (heap->locked == RT_FALSE)
510510
{
511511
/* lock memheap */
512512
result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER);
@@ -577,7 +577,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
577577
/* increment the available byte count. */
578578
heap->available_size = heap->available_size + MEMITEM_SIZE(new_ptr);
579579

580-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
580+
if (heap->locked == RT_FALSE)
581581
{
582582
/* release lock */
583583
rt_sem_release(&(heap->lock));
@@ -630,7 +630,7 @@ void rt_memheap_free(void *ptr)
630630
RT_ASSERT(heap);
631631
RT_ASSERT(rt_object_get_type(&heap->parent) == RT_Object_Class_MemHeap);
632632

633-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
633+
if (heap->locked == RT_FALSE)
634634
{
635635
/* lock memheap */
636636
result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER);
@@ -716,7 +716,7 @@ void rt_memheap_free(void *ptr)
716716
rt_memset(header_ptr->owner_thread_name, ' ', sizeof(header_ptr->owner_thread_name));
717717
#endif /* RT_USING_MEMTRACE */
718718

719-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
719+
if (heap->locked == RT_FALSE)
720720
{
721721
/* release lock */
722722
rt_sem_release(&(heap->lock));
@@ -744,7 +744,7 @@ void rt_memheap_info(struct rt_memheap *heap,
744744
{
745745
rt_err_t result;
746746

747-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
747+
if (heap->locked == RT_FALSE)
748748
{
749749
/* lock memheap */
750750
result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER);
@@ -764,7 +764,7 @@ void rt_memheap_info(struct rt_memheap *heap,
764764
if (max_used != RT_NULL)
765765
*max_used = heap->max_used_size;
766766

767-
if (heap->locked == RT_FALSE && rt_thread_self() != RT_NULL)
767+
if (heap->locked == RT_FALSE)
768768
{
769769
/* release lock */
770770
rt_sem_release(&(heap->lock));

0 commit comments

Comments
 (0)