Skip to content

Commit 80ddfd2

Browse files
committed
fixed some bugs
1 parent bcd4f2e commit 80ddfd2

File tree

6 files changed

+127
-56
lines changed

6 files changed

+127
-56
lines changed

MProkaron/Benchmark/test.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
void Func_1(void* Param)
44
{
5-
ptr_t Time=0;
65
while(1)
76
{
87
RMP_Thd_Delay(30000);
9-
RMP_Thd_Snd(&Thd_2, Time, RMP_MAX_SLICES);
10-
Time++;
8+
RMP_Sem_Post(&Sem_1, 1);
119
};
1210
}
1311

@@ -16,15 +14,15 @@ void Func_2(void* Param)
1614
ptr_t Data;
1715
while(1)
1816
{
19-
RMP_Thd_Rcv(&Data, RMP_MAX_SLICES);
20-
RMP_PRINTK_S("Received ");
21-
RMP_PRINTK_I(Data);
22-
RMP_PRINTK_S("\r\n\r\n");
17+
RMP_Sem_Pend(&Sem_1, RMP_MAX_SLICES);
18+
RMP_PRINTK_S("Semaphore successfully acquired!\r\n\r\n");
2319
};
2420
}
2521

2622
void RMP_Init_Hook(void)
2723
{
24+
/* Counting semaphore */
25+
RMP_Sem_Crt(&Sem_1,0);
2826
/* Start threads */
2927
RMP_Thd_Crt(&Thd_1, Func_1, &Stack_1[238], (void*)0x12345678, 1, 5);
3028
RMP_Thd_Crt(&Thd_2, Func_2, &Stack_2[238], (void*)0x87654321, 1, 5);

MProkaron/Benchmark/test.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct RMP_Thd Thd_1={0};
4949
ptr_t Stack_2[256];
5050
struct RMP_Thd Thd_2={0};
5151

52+
struct RMP_Sem Sem_1={0};
53+
5254
ptr_t Time;
5355

5456

MProkaron/Kernel/kernel.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,10 @@ ret_t RMP_Sem_Pend(struct RMP_Sem* Semaphore, ptr_t Slices)
12441244
return RMP_ERR_OPER;
12451245
}
12461246

1247-
/* We must be running */
1247+
/* We must be running - place into waitlist now */
12481248
_RMP_Clr_Rdy(RMP_Cur_Thd);
1249-
1249+
RMP_List_Ins(&(RMP_Cur_Thd->Run_Head),Semaphore->Wait_List.Prev,&(Semaphore->Wait_List));
1250+
12501251
if(Slices<RMP_MAX_SLICES)
12511252
{
12521253
_RMP_Dly_Ins(RMP_Cur_Thd, Slices);
@@ -1345,7 +1346,7 @@ ret_t RMP_Sem_Post(struct RMP_Sem* Semaphore, ptr_t Number)
13451346

13461347
Semaphore->Cur_Num+=Number;
13471348
/* Is there any thread waiting on it? If there are, clean them up*/
1348-
while((&(Semaphore->Wait_List)!=Semaphore->Wait_List.Next)||(Semaphore->Cur_Num==0))
1349+
while((&(Semaphore->Wait_List)!=Semaphore->Wait_List.Next)&&(Semaphore->Cur_Num!=0))
13491350
{
13501351
Thread=(struct RMP_Thd*)(Semaphore->Wait_List.Next);
13511352
RMP_List_Del(Thread->Run_Head.Prev,Thread->Run_Head.Next);

Project/RVMDK-STM32F767IGT6/RTOS-Mutate.uvguix.pry

Lines changed: 53 additions & 44 deletions
Large diffs are not rendered by default.

Project/RVMDK-STM32F767IGT6/RTOS-Mutate.uvoptx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,40 @@
160160
<Name>-T0</Name>
161161
</SetRegEntry>
162162
</TargetDriverDllRegistry>
163-
<Breakpoint/>
163+
<Breakpoint>
164+
<Bp>
165+
<Number>0</Number>
166+
<Type>0</Type>
167+
<LineNumber>17</LineNumber>
168+
<EnabledFlag>1</EnabledFlag>
169+
<Address>134218486</Address>
170+
<ByteObject>0</ByteObject>
171+
<HtxType>0</HtxType>
172+
<ManyObjects>0</ManyObjects>
173+
<SizeOfObject>0</SizeOfObject>
174+
<BreakByAccess>0</BreakByAccess>
175+
<BreakIfRCount>1</BreakIfRCount>
176+
<Filename>..\..\MProkaron\Benchmark\test.c</Filename>
177+
<ExecCommand></ExecCommand>
178+
<Expression>\\RMP\../../MProkaron/Benchmark/test.c\17</Expression>
179+
</Bp>
180+
<Bp>
181+
<Number>1</Number>
182+
<Type>0</Type>
183+
<LineNumber>8</LineNumber>
184+
<EnabledFlag>1</EnabledFlag>
185+
<Address>0</Address>
186+
<ByteObject>0</ByteObject>
187+
<HtxType>0</HtxType>
188+
<ManyObjects>0</ManyObjects>
189+
<SizeOfObject>0</SizeOfObject>
190+
<BreakByAccess>0</BreakByAccess>
191+
<BreakIfRCount>0</BreakIfRCount>
192+
<Filename>..\..\MProkaron\Benchmark\test.c</Filename>
193+
<ExecCommand></ExecCommand>
194+
<Expression></Expression>
195+
</Bp>
196+
</Breakpoint>
164197
<WatchWindow1>
165198
<Ww>
166199
<count>0</count>

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This operating system is much **leaner** than any other RTOSes, especilly when c
4848
}
4949
```
5050
### Send from one thread to another
51-
![Delay](https://raw.githubusercontent.com/EDI-Systems/M5P1_MuProkaron/master/Documents/Demo/Send.gif)
51+
![Send](https://raw.githubusercontent.com/EDI-Systems/M5P1_MuProkaron/master/Documents/Demo/Send.gif)
5252
```C
5353
void Func_1(void* Param)
5454
{
@@ -81,6 +81,34 @@ This operating system is much **leaner** than any other RTOSes, especilly when c
8181
```
8282

8383
### Counting semaphores
84+
![Semaphore](https://raw.githubusercontent.com/EDI-Systems/M5P1_MuProkaron/master/Documents/Demo/Semaphore.gif)
85+
```C
86+
void Func_1(void* Param)
87+
{
88+
while(1)
89+
{
90+
RMP_Thd_Delay(30000);
91+
RMP_Sem_Post(&Sem_1, 1);
92+
};
93+
}
94+
95+
void Func_2(void* Param)
96+
{
97+
ptr_t Data;
98+
while(1)
99+
{
100+
RMP_Sem_Pend(&Sem_1, RMP_MAX_SLICES);
101+
RMP_PRINTK_S("Semaphore successfully acquired!\r\n\r\n");
102+
};
103+
}
104+
105+
void RMP_Init_Hook(void)
106+
{
107+
RMP_Sem_Crt(&Sem_1,0);
108+
RMP_Thd_Crt(&Thd_1, Func_1, &Stack_1[238], (void*)0x12345678, 1, 5);
109+
RMP_Thd_Crt(&Thd_2, Func_2, &Stack_2[238], (void*)0x87654321, 1, 5);
110+
}
111+
```
84112
85113
### Typical performance figures
86114
|Machine |Toolchain |Flash|SRAM|Yield|Mailbox|Semaphore|Mailbox/Int|Semaphore/Int|

0 commit comments

Comments
 (0)