optee的同步机制总结
来源:互联网 发布:大数据 方便面 编辑:程序博客网 时间:2024/05/29 16:59
optee有三种同步机制分别是spin-lock/mutex/condvar
1:spin-lock举例如下:
spin-lock 是一个unsigned int类型的变量,总共有三个函数
| Function | Purpose |
|----------|---------|
| `cpu_spin_lock()` | Locks a spin-lock |
| `cpu_spin_trylock()` | Locks a spin-lock if unlocked and returns `0` else the spin-lock is unchanged and the function returns `!0`|
| `cpu_spin_unlock()` | Unlocks a spin-lock |
static unsigned int rng_lock = SPINLOCK_UNLOCK;
cpu_spin_lock(&rng_lock);
ret = random.byte[pos];
pos = (pos + 1) % 8;
cpu_spin_unlock(&rng_lock);
2:mutex举例如下:
mutex 是一个struct mutex或者mutex_init()来初始化一个mutex变量
相关函数有四个
可以使用MUTEX_INITIALIZER和mutex_init()来初始化一个mutex变量
| Function | Purpose |
|----------|---------|
|`mutex_lock()` | Locks a mutex. If the mutex is unlocked this is a fast operation, else the function issues an RPC to wait in normal world. |
| `mutex_unlock()` | Unlocks a mutex. If there is no waiters this is a fast operation, else the function issues an RPC to wake up a waiter in normal world. |
| `mutex_trylock()` | Locks a mutex if unlocked and returns `true` else the mutex is unchanged and the function returns `false`. |
| `mutex_destroy()` | Asserts that the mutex is unlocked and there is no waiters, after this the memory used by the mutex can be freed. |
3:condvar举例如下:
condvar 用struct condvar来表示
可以使用CONDVAR_INITIALIZER和condvar_init()来初始化一个condvar变量,相关函数有三个
| Function | Purpose |
|----------|---------|
| `condvar_wait()` | Atomically unlocks the supplied mutex and waits in normal world via an RPC for the condition variable to be signaled, when the function returns the mutex is locked again. |
| `condvar_signal()` | Wakes up one waiter of the condition variable (waiting in `condvar_wait()`) |
| `condvar_broadcast()` | Wake up all waiters of the condition variable. |
1:spin-lock举例如下:
spin-lock 是一个unsigned int类型的变量,总共有三个函数
| Function | Purpose |
|----------|---------|
| `cpu_spin_lock()` | Locks a spin-lock |
| `cpu_spin_trylock()` | Locks a spin-lock if unlocked and returns `0` else the spin-lock is unchanged and the function returns `!0`|
| `cpu_spin_unlock()` | Unlocks a spin-lock |
static unsigned int rng_lock = SPINLOCK_UNLOCK;
cpu_spin_lock(&rng_lock);
ret = random.byte[pos];
pos = (pos + 1) % 8;
cpu_spin_unlock(&rng_lock);
2:mutex举例如下:
mutex 是一个struct mutex或者mutex_init()来初始化一个mutex变量
相关函数有四个
可以使用MUTEX_INITIALIZER和mutex_init()来初始化一个mutex变量
| Function | Purpose |
|----------|---------|
|`mutex_lock()` | Locks a mutex. If the mutex is unlocked this is a fast operation, else the function issues an RPC to wait in normal world. |
| `mutex_unlock()` | Unlocks a mutex. If there is no waiters this is a fast operation, else the function issues an RPC to wake up a waiter in normal world. |
| `mutex_trylock()` | Locks a mutex if unlocked and returns `true` else the mutex is unchanged and the function returns `false`. |
| `mutex_destroy()` | Asserts that the mutex is unlocked and there is no waiters, after this the memory used by the mutex can be freed. |
3:condvar举例如下:
condvar 用struct condvar来表示
可以使用CONDVAR_INITIALIZER和condvar_init()来初始化一个condvar变量,相关函数有三个
| Function | Purpose |
|----------|---------|
| `condvar_wait()` | Atomically unlocks the supplied mutex and waits in normal world via an RPC for the condition variable to be signaled, when the function returns the mutex is locked again. |
| `condvar_signal()` | Wakes up one waiter of the condition variable (waiting in `condvar_wait()`) |
| `condvar_broadcast()` | Wake up all waiters of the condition variable. |
阅读全文
0 0
- optee的同步机制总结
- optee的generic_boot_init_primary 分析
- optee thread的初始化
- optee 的helloworld ta
- optee中的fiq的执行
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- Java的synchronized关键字:同步机制总结
- ava的synchronized关键字:同步机制总结
- java 如何输入一个字符
- h5微信支付核心代码
- 图像处理: 灰度化,二值化,反色
- 最小费用购物问题
- IE浏览器Cookie信息提取工具Galleta
- optee的同步机制总结
- Day03-JavaScript03
- Oracle 创建与删除job小例子
- web前端规划
- iOS键盘删除健删除表情
- bzoj 3509: [CodeChef] COUNTARI (FFT+分块)
- 基于JavaMail的Java邮件发送:简单邮件发送
- 28 atomic_t原子数与原子位操作
- [BZOJ 1013][JSOI2008]球形空间产生器sphere:高斯消元