Jaydeep Shah
/
21_MUTEX_LOCK_UNLOCK
MUTEX and its use in MBED MUTEX LOCK and Unlock mechanism
Revision 1:605f5624661e, committed 2020-07-26
- Comitter:
- radhey04ec
- Date:
- Sun Jul 26 10:59:21 2020 +0000
- Parent:
- 0:b908013d70cd
- Child:
- 2:0cf7e435eeb8
- Commit message:
- UPDATE to clear confusion of priority of thread and mutex. But there is no relation. prinf misguide me
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jul 25 09:46:26 2020 +0000 +++ b/main.cpp Sun Jul 26 10:59:21 2020 +0000 @@ -1,9 +1,8 @@ -/* 21_ MUTEX a Guard at door - Basic program (All thread with same priority level) +/* 21_ MUTEX a Guard at door - Basic program MUTEX allow only one Thread / Function call inside CS, Mutex have ownership type locking mechanism. Procees /or Thread who locked block,only same process /or thread can unlock it. */ -//BUGS in MUTEX CLASS -//NOTE : MUTEX ONLY PROTECT CS from processes which are belonging same priority level -MBED BUG + //PROGRAM CREATED BY : JAYDEEP SHAH -- radheec@gmail.com //DATE : 25 JULY 20 ,VERSION 1.0 @@ -17,9 +16,9 @@ //Create Two Thread -Thread t2; //Create Thread with high priority +Thread t2; -Thread t3; //Create Thread with low priority +Thread t3; //Here below section act as CS critical section @@ -32,9 +31,12 @@ printf("This Thread lock the code %s: %d\n\r", name, state); wait(0.5); //sleep + printf("Thread cross & unlock %s: %d\n\r", name, state); //OUTSIDE CODE BLOCK --------- + M_LOCK.unlock(); //After completing task unlock the code ------------- UNLOCK THE BLOCK - printf("Thread cross & unlock %s: %d\n\r", name, state); //OUTSIDE CODE BLOCK --------- +//DO NOT WRITE any print statement after unlock() it create missunderstanding .... +/* print statement require more clk cycle,after unlock the MUTEX Flag - schedular quickly schedule next thread before print the statement.*/ }
--- a/mbed-os.lib Sat Jul 25 09:46:26 2020 +0000 +++ b/mbed-os.lib Sun Jul 26 10:59:21 2020 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9 +https://github.com/ARMmbed/mbed-os/#3ab72c71b75cb9cb91160a54fba22ec43b036ed2