Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esp32/mpthreadport: Use binary semaphore instead of mutex.
So a lock can be acquired on one Python thread and then released on another. A test for this is added. Signed-off-by: Damien George <damien@micropython.org>
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# test _thread lock objects where a lock is acquired/released by a different thread | ||
|
||
import _thread | ||
|
||
|
||
def thread_entry(): | ||
print("thread about to release lock") | ||
lock.release() | ||
|
||
|
||
lock = _thread.allocate_lock() | ||
lock.acquire() | ||
_thread.start_new_thread(thread_entry, ()) | ||
lock.acquire() | ||
print("main has lock") | ||
lock.release() |