-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] Use a mutex guard for split shared memory (#16647)
- Loading branch information
Showing
6 changed files
with
82 additions
and
20 deletions.
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
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,26 @@ | ||
// Copyright 2022 Stefan Kerkmann | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include "synchronization_util.h" | ||
#include "ch.h" | ||
|
||
#if defined(SPLIT_KEYBOARD) | ||
static MUTEX_DECL(SPLIT_SHARED_MEMORY_MUTEX); | ||
|
||
/** | ||
* @brief Acquire exclusive access to the split keyboard shared memory, by | ||
* locking the mutex guarding it. If the mutex is already held, the calling | ||
* thread will be suspended until the mutex currently owning thread releases the | ||
* mutex again. | ||
*/ | ||
void split_shared_memory_lock(void) { | ||
chMtxLock(&SPLIT_SHARED_MEMORY_MUTEX); | ||
} | ||
|
||
/** | ||
* @brief Release the split shared memory mutex that has been acquired before. | ||
*/ | ||
void split_shared_memory_unlock(void) { | ||
chMtxUnlock(&SPLIT_SHARED_MEMORY_MUTEX); | ||
} | ||
#endif |
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,14 @@ | ||
// Copyright 2022 Stefan Kerkmann | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#if defined(PLATFORM_SUPPORTS_SYNCHRONIZATION) | ||
# if defined(SPLIT_KEYBOARD) | ||
void split_shared_memory_lock(void); | ||
void split_shared_memory_unlock(void); | ||
# endif | ||
#else | ||
inline void split_shared_memory_lock(void){}; | ||
inline void split_shared_memory_unlock(void){}; | ||
#endif |
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