本文整理汇总了C++中rt_mutex_take函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_mutex_take函数的具体用法?C++ rt_mutex_take怎么用?C++ rt_mutex_take使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_mutex_take函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dfs_jffs2_close
static int dfs_jffs2_close(struct dfs_fd* file)
{
int result;
cyg_file * jffs2_file;
RT_ASSERT(file->data != NULL);
jffs2_file = (cyg_file *)(file->data);
if (file->flags & DFS_O_DIRECTORY) /* operations about dir */
{
rt_mutex_take(&jffs2_lock, RT_WAITING_FOREVER);
result = jffs2_dir_colse(jffs2_file);
rt_mutex_release(&jffs2_lock);
if (result)
return jffs2_result_to_dfs(result);
rt_free(jffs2_file);
return 0;
}
/* regular file operations */
rt_mutex_take(&jffs2_lock, RT_WAITING_FOREVER);
result = jffs2_file_colse(jffs2_file);
rt_mutex_release(&jffs2_lock);
if (result)
return jffs2_result_to_dfs(result);
/* release memory */
rt_free(jffs2_file);
return 0;
}
开发者ID:QiuGong,项目名称:Terminal,代码行数:30,代码来源:dfs_jffs2.c
示例2: thread1_entry
static void thread1_entry(void* parameter)
{
rt_err_t result;
result = rt_mutex_take(mutex, RT_WAITING_FOREVER);
result = rt_mutex_take(mutex, RT_WAITING_FOREVER);
rt_kprintf("thread1: got mutex\n");
if (result != RT_EOK)
{
return;
}
for(t1_count = 0; t1_count < 5;t1_count ++)
{
rt_kprintf("thread1:count: %d\n", t1_count);
}
if (t2->current_priority != t1->current_priority)
{
rt_kprintf("thread1: released mutex\n");
rt_mutex_release(mutex);
rt_mutex_release(mutex);
}
}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:26,代码来源:demo.c
示例3: lcd1602_DispProcessing
void lcd1602_DispProcessing(uint8_t percent)
{
uint8_t i, BlockNum = 0;
uint8_t abyString[17];
rt_err_t rtResult;
//while (1)
{
BlockNum = ((uint32_t)percent * 16) / 99;
for (i = 0; i < 16; i++)
{
if (i < BlockNum)
{
abyString [i] = '#';
}
else
{
abyString [i] = ' ';
}
}
abyString[16] = 0;
rtResult = rt_mutex_take(LcdMutex, RT_WAITING_FOREVER);
if (rtResult == RT_EOK)
{
LCD_PutStr(abyString, 16, 16);
rt_mutex_release(LcdMutex);
}
}
}
开发者ID:xiamin,项目名称:TA_D,代码行数:29,代码来源:tad_LCD.c
示例4: rt_spi_transfer
rt_size_t rt_spi_transfer(struct rt_spi_device *device,
const void *send_buf,
void *recv_buf,
rt_size_t length)
{
rt_err_t result;
struct rt_spi_message message;
RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->bus != RT_NULL);
result = rt_mutex_take(&(device->bus->lock), RT_WAITING_FOREVER);
if (result == RT_EOK)
{
if (device->bus->owner != device)
{
/* not the same owner as current, re-configure SPI bus */
result = device->bus->ops->configure(device, &device->config);
if (result == RT_EOK)
{
/* set SPI bus owner */
device->bus->owner = device;
}
else
{
/* configure SPI bus failed */
rt_set_errno(-RT_EIO);
result = 0;
goto __exit;
}
}
/* initial message */
message.send_buf = send_buf;
message.recv_buf = recv_buf;
message.length = length;
message.cs_take = 1;
message.cs_release = 1;
message.next = RT_NULL;
/* transfer message */
result = device->bus->ops->xfer(device, &message);
if (result == 0)
{
rt_set_errno(-RT_EIO);
goto __exit;
}
}
else
{
rt_set_errno(-RT_EIO);
return 0;
}
__exit:
rt_mutex_release(&(device->bus->lock));
return result;
}
开发者ID:Bluebear233,项目名称:rt-thread-stm32f103,代码行数:60,代码来源:spi_core.c
示例5: I2C_AcknowledgePolling
/*TODO: If your device need more time to initialize I2C bus or waiting memory write, you can use I2C_AcknowledgePolling avoid I2C bus lose.*/
Status I2C_AcknowledgePolling(I2C_TypeDef* I2Cx ,uint8_t Addr)
{
uint32_t timeout = 0xFFFF, ret;
uint16_t tmp;
ret = rt_mutex_take(i2c_mux, RT_WAITING_FOREVER );
if( ret == RT_EOK )
{
do{
if( timeout-- <= 0 )
{
I2C_ClearFlag(I2Cx,I2C_FLAG_AF);
I2Cx->CR1 |= CR1_STOP_Set;
rt_mutex_release(i2c_mux);
return Error;
}
I2Cx->CR1 |= CR1_START_Set;
tmp = I2Cx->SR1;//²M°£SB¦ì
I2Cx->DR = Addr;
}while((I2Cx->SR1&0x0002) != 0x0002);
I2C_ClearFlag(I2Cx,I2C_FLAG_AF);
I2Cx->CR1 |= CR1_STOP_Set;
while ((I2Cx->CR1&0x200) == 0x200);
rt_kprintf( "AcknowledgePolling OK\n");
rt_mutex_release(i2c_mux);
return Success;
}
else
return Error;
}
开发者ID:bright-pan,项目名称:smart-lock,代码行数:34,代码来源:i2c.c
示例6: rt_spi_configure
rt_err_t rt_spi_configure(struct rt_spi_device* device, struct rt_spi_configuration* cfg)
{
rt_err_t result;
RT_ASSERT(device != RT_NULL);
/* set configuration */
device->config.data_width = cfg->data_width;
device->config.mode = cfg->mode & RT_SPI_MODE_MASK ;
device->config.max_hz = cfg->max_hz ;
if (device->bus != RT_NULL)
{
result = rt_mutex_take(&(device->bus->lock), RT_WAITING_FOREVER);
if (result == RT_EOK)
{
if (device->bus->owner == device)
{
device->bus->ops->configure(device, &device->config);
}
/* release lock */
rt_mutex_release(&(device->bus->lock));
}
}
return RT_EOK;
}
开发者ID:Manish-cimcon,项目名称:micro,代码行数:28,代码来源:spi_core.c
示例7: rt_i2c_transfer
rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num)
{
rt_size_t ret;
if (bus->ops->master_xfer)
{
#ifdef RT_I2C_DEBUG
for (ret = 0; ret < num; ret++)
{
i2c_dbg("msgs[%d] %c, addr=0x%02x, len=%d%s\n", ret,
(msgs[ret].flags & RT_I2C_RD) ? 'R' : 'W',
msgs[ret].addr, msgs[ret].len);
}
#endif
rt_mutex_take(&bus->lock, RT_WAITING_FOREVER);
ret = bus->ops->master_xfer(bus, msgs, num);
rt_mutex_release(&bus->lock);
return ret;
}
else
{
i2c_dbg("I2C bus operation not supported\n");
return 0;
}
}
开发者ID:AdrianHuang,项目名称:rt-thread-for-vmm,代码行数:30,代码来源:i2c_core.c
示例8: ff_req_grant
int ff_req_grant(_SYNC_t m)
{
if (rt_mutex_take(m, _FS_TIMEOUT) == RT_EOK)
return RT_TRUE;
return RT_FALSE;
}
开发者ID:comrid1987,项目名称:jb3500,代码行数:7,代码来源:dfs_elm.c
示例9: pthread_mutex_lock
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
int mtype;
rt_err_t result;
if (!mutex) return EINVAL;
if (mutex->attr == -1)
{
/* init mutex */
pthread_mutex_init(mutex, RT_NULL);
}
mtype = mutex->attr & MUTEXATTR_TYPE_MASK;
rt_enter_critical();
if (mutex->lock.owner == rt_thread_self() && mtype != PTHREAD_MUTEX_RECURSIVE)
{
rt_exit_critical();
return EDEADLK;
}
rt_exit_critical();
result = rt_mutex_take(&(mutex->lock), RT_WAITING_FOREVER);
if (result == RT_EOK) return 0;
return EINVAL;
}
开发者ID:bobo8909,项目名称:RTT,代码行数:27,代码来源:pthread_mutex.c
示例10: sys_mutex_lock
/** Lock a mutex
* @param mutex the mutex to lock
*/
void sys_mutex_lock(sys_mutex_t *mutex)
{
RT_DEBUG_NOT_IN_INTERRUPT;
rt_mutex_take(*mutex, RT_WAITING_FOREVER);
return;
}
开发者ID:AdrianHuang,项目名称:rt-thread-for-vmm,代码行数:10,代码来源:sys_arch.c
示例11: dfs_jffs2_write
static int dfs_jffs2_write(struct dfs_fd* file,
const void* buf,
rt_size_t len)
{
cyg_file * jffs2_file;
struct CYG_UIO_TAG uio_s;
struct CYG_IOVEC_TAG iovec;
int char_write;
int result;
RT_ASSERT(file->data != NULL);
jffs2_file = (cyg_file *)(file->data);
uio_s.uio_iov = &iovec;
uio_s.uio_iov->iov_base = (void *)buf;
uio_s.uio_iov->iov_len = len;
uio_s.uio_iovcnt = 1; //must be 1
//uio_s.uio_offset //not used...
uio_s.uio_resid = uio_s.uio_iov->iov_len; //seem no use in jffs2;
char_write = jffs2_file->f_offset;
rt_mutex_take(&jffs2_lock, RT_WAITING_FOREVER);
result = jffs2_file_write(jffs2_file, &uio_s);
rt_mutex_release(&jffs2_lock);
if (result)
return jffs2_result_to_dfs(result);
/* update position */
file->pos = jffs2_file->f_offset;
char_write = jffs2_file->f_offset - char_write;
return char_write;
}
开发者ID:QiuGong,项目名称:Terminal,代码行数:31,代码来源:dfs_jffs2.c
示例12: dfs_lock
/**
* this function will lock device file system.
*
* @note please don't invoke it on ISR.
*/
void dfs_lock(void)
{
rt_err_t result;
result = rt_mutex_take(&fslock, RT_WAITING_FOREVER);
if (result != RT_EOK)
{
RT_ASSERT(0);
}
}
开发者ID:dlts200466,项目名称:PowerSupply,代码行数:15,代码来源:dfs.c
示例13: telnet_read
static rt_size_t telnet_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
{
rt_size_t result;
/* read from rx ring buffer */
rt_mutex_take(telnet->rx_ringbuffer_lock, RT_WAITING_FOREVER);
result = rt_ringbuffer_get(&(telnet->rx_ringbuffer), buffer, size);
rt_mutex_release(telnet->rx_ringbuffer_lock);
return result;
}
开发者ID:onelife,项目名称:rt-thread,代码行数:11,代码来源:telnet.c
示例14: thread2_entry
static void thread2_entry(void* parameter)
{
rt_thread_delay(5);
rt_mutex_take(mutex, RT_WAITING_FOREVER);
rt_kprintf("thread2: got mutex\n");
for(t2_count = 0; t2_count < 5;t2_count ++)
{
rt_kprintf("thread2: count: %d\n", t2_count);
}
}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:11,代码来源:demo.c
示例15: rt_thread_entry2
static void rt_thread_entry2(void* parameter)
{
rt_err_t result;
rt_tick_t tick;
/* 1. static mutex test */
rt_kprintf("thread2 try to get static mutex\n");
rt_mutex_take(&static_mutex, 10);
rt_kprintf("thread2 got static mutex\n");
rt_thread_delay(RT_TICK_PER_SECOND);
rt_kprintf("thread2 release static mutex\n");
rt_mutex_release(&static_mutex);
/* 2. dynamic mutex test */
rt_kprintf("thread2 try to get dynamic mutex\n");
rt_mutex_take(dynamic_mutex, 10);
rt_kprintf("thread2 got dynamic mutex\n");
rt_thread_delay(RT_TICK_PER_SECOND);
rt_kprintf("thread2 release dynamic mutex\n");
rt_mutex_release(dynamic_mutex);
}
开发者ID:15863118785,项目名称:realtouch-stm32f4,代码行数:21,代码来源:application.c
示例16: hm_heatcal_thread_entry
void hm_heatcal_thread_entry(void* parameter)
{
rt_uint32_t event_set = 0;
float heat_used = 0;
cal_event = rt_event_create("H_cal", RT_IPC_FLAG_FIFO);
RT_ASSERT(cal_event);
while(1) {
if(rt_event_recv(cal_event, TDC_DATA_FULL_EVENT,
RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER,
&event_set)==RT_EOK) {
if((rt_mutex_take(temp_lock, rt_tick_from_millisecond(LOCK_TACK_WAIT_TIME_MS)) ||
(rt_mutex_take(tof_lock, rt_tick_from_millisecond(LOCK_TACK_WAIT_TIME_MS)))) != RT_EOK) {
rt_kprintf("TOF and temprature take lock error\n");
}
heat_used += do_heat_cal();
rt_mutex_release(tof_lock);
rt_mutex_release(temp_lock);
heat_print(heat_used);
}
}
}
开发者ID:leon008wlo,项目名称:heat_meter_rtt,代码行数:22,代码来源:heat_senser.c
示例17: osMutexWait
/// Wait until a Mutex becomes available
osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec)
{
rt_err_t result;
rt_tick_t ticks;
ticks = rt_tick_from_millisecond(millisec);
result = rt_mutex_take(mutex_id, ticks);
if (result == RT_EOK)
return osOK;
else
return osErrorOS;
}
开发者ID:Paolo-Maffei,项目名称:rt-thread-stm32f4discovery,代码行数:14,代码来源:cmsis_rtthread.c
示例18: AddTestIndex
int AddTestIndex(struct TestIndexListStc til)
{
int pos=ReadAllTestIndex();
struct TestIndexListStc *ti = NULL;
ti = &TestIndexListEnd;
struct TestIndexListStc *pti=NULL;
pti=malloc(sizeof(TestIndexList));//c0
ti->next = pti;//c1
pti = ti;//c2
ti = ti->next;//c3
ti->pre = pti;//c4
ti->next = NULL;//c5
pos++;
ti->ti=pos;
ti->del=0;
ti->time=til.time;
memcpy(&ti->unit,&til.time,sizeof(til.time));
memcpy(&ti->TestLocA,&til.TestLocA,sizeof(til.TestLocA));
memcpy(&ti->TestLocB,&til.TestLocB,sizeof(til.TestLocA));
memcpy(&ti->TestLocC,&til.TestLocC,sizeof(til.TestLocA));
ti->a1=til.a1;
ti->a2=til.a2;
ti->b1=til.b1;
ti->b2=til.b2;
TestIndexListEnd=*ti;
UINT8 tfwrbuf[TFCARD_BLOCK_SIZE];
memcpy(tfwrbuf,&TestIndexListEnd,sizeof(TestIndexListEnd));
rt_uint8_t idxpath[10];
CreatePath(TestIndexListEnd.pos,idxpath);
rt_err_t result = rt_mutex_take(&tfio_mutex, RT_WAITING_NO);
//update testindex.bin
CH378FileOpen(tibin);
CH378SecLocate(SECEND);
PUINT8 realcnt;
CH378SecWrite(tfwrbuf,1,realcnt);
if(*realcnt<1)
{
//write error
}
//create index.bin
status=CH378FileCreate(idxpath);
CH378FileClose(1);
rt_mutex_release(&tfio_mutex);
return -1;
}
开发者ID:aileenfun,项目名称:ArmFirmware,代码行数:51,代码来源:tfcard.c
示例19: pthread_mutex_trylock
int pthread_mutex_trylock(pthread_mutex_t *mutex)
{
rt_err_t result;
if (!mutex) return EINVAL;
if (mutex->attr == -1) {
/* init mutex */
pthread_mutex_init(mutex, RT_NULL);
}
result = rt_mutex_take(&(mutex->lock), 0);
if (result == RT_EOK) return 0;
return EBUSY;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:15,代码来源:pthread_mutex.c
示例20: send_option_to_client
/* send telnet option to remote */
static void send_option_to_client(struct telnet_session* telnet, rt_uint8_t option, rt_uint8_t value)
{
rt_uint8_t optbuf[4];
optbuf[0] = TELNET_IAC;
optbuf[1] = option;
optbuf[2] = value;
optbuf[3] = 0;
rt_mutex_take(telnet->tx_ringbuffer_lock, RT_WAITING_FOREVER);
rt_ringbuffer_put(&telnet->tx_ringbuffer, optbuf, 3);
rt_mutex_release(telnet->tx_ringbuffer_lock);
send_to_client(telnet);
}
开发者ID:onelife,项目名称:rt-thread,代码行数:16,代码来源:telnet.c
注:本文中的rt_mutex_take函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论