本文整理汇总了C++中RELEASE_LOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ RELEASE_LOCK函数的具体用法?C++ RELEASE_LOCK怎么用?C++ RELEASE_LOCK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RELEASE_LOCK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: channel_clear
int
channel_clear(void)
{
int cca;
int radio_was_off = 0;
PRINTF("CCA\n");
/* If the radio is locked by an underlying thread (because we are
being invoked through an interrupt), we preted that the coast is
clear (i.e., no packet is currently being transmitted by a
neighbor). */
if(locked) {
return 1;
}
GET_LOCK();
if(!receive_on) {
radio_was_off = 1;
cc2520_on();
}
/* Make sure that the radio really got turned on. */
if(!receive_on) {
RELEASE_LOCK();
if(radio_was_off) {
cc2520_off();
}
return 1;
}
cca = cc2520ll_channel_clear();
if(radio_was_off) {
cc2520_off();
}
RELEASE_LOCK();
return cca;
}
示例2: ListFree
PRIVATE
void
ListFree( void * unit )
{
int done = FALSE;
LIST_UNIT * lu;
ALLOC_UNIT * t = NULL;
ALLOC_UNIT * tbl = NULL;
WAIT_FOR_LOCK( LIST_MUTEX );
for( t = GLOBAL_ALLOC_TABLE; t; t = (ALLOC_UNIT *)tbl -> prev )
tbl = t;
if( !tbl )
{
DBG(PF( "Error freeing list structure.\n" ));
RELEASE_LOCK( LIST_MUTEX );
return;
}
lu = (LIST_UNIT *)( (int) unit - sizeof( int ) );
if( lu -> check != ALLOC_USED_FLAG )
{
ERROR( "Free of a corrupt list node from allocation table." );
RELEASE_LOCK( LIST_MUTEX );
return;
}
do
{
if ( (unit >= tbl -> min) && (unit < tbl -> max) )
{
tbl -> avail++;
lu -> check = ALLOC_FREE_FLAG;
lu -> ptr_a = NULL;
lu -> ptr_b = NULL;
lu -> ptr_c = NULL;
done = TRUE;
break;
}
else
{
tbl = (ALLOC_UNIT *)tbl -> next;
}
} while( tbl && !done );
if ( !done )
ERROR( "Couldn't find list in allocation table\n" );
RELEASE_LOCK( LIST_MUTEX );
}
示例3: Parse
NET_API_STATUS
Parse(
IN DWORD argc,
IN LPTSTR argv[]
)
/*++
Routine Description :
Wrapper function of the real worker Parse2 function.
Arguments :
argc : argument count
argv : argument string array pointer.
Return Value :
return NO_ERROR if successfully parse parameter
ERROR_INVALID_PARAMETER, otherwise
--*/
{
NET_API_STATUS ApiStatus;
LPNET_CONFIG_HANDLE ConfigHandle;
// Get read-write lock for config data. (The lock is for the in-memory
// version of the data, which we're going to set.)
ACQUIRE_LOCK( ReplGlobalConfigLock );
// Open the config file (nt.cfg)
ApiStatus = NetpOpenConfigData(
& ConfigHandle,
NULL, // local machine
SECT_NT_REPLICATOR, // section name
TRUE); // read-only
if (ApiStatus != NO_ERROR) {
NetpKdPrint(( "[REPL] Parse() can't open config section.\n" ));
ReplFinish(
SERVICE_UIC_CODE(
SERVICE_UIC_SYSTEM,
ApiStatus),
NULL);
RELEASE_LOCK( ReplGlobalConfigLock );
return( ApiStatus );
}
ApiStatus = Parse2(argc, argv, ConfigHandle);
// close config file ..
(void) NetpCloseConfigData( ConfigHandle );
RELEASE_LOCK( ReplGlobalConfigLock );
return( ApiStatus );
}
示例4: rtp_sinker_consume
static int32_t
rtp_sinker_consume(network_sinker *ns, proto_watch *pw,
int32_t stm_i, msg *m, uint32_t seq)
{
int32_t ret = -ENOMEM;
media_sinker *sinker = (media_sinker*)ns;
rtp_sinker *rs = (rtp_sinker*)ns;
media_sinker *ms = (media_sinker*)ns;
mem_block *mb;
network_client *nc = (network_client*)rs->interleaved;
if (rs->trans_mode == RTP_OVER_UDP)
{
BUG_ON(!pw);
proto_watch_ref(pw);
RELEASE_LOCK(sinker->lock);
msg_ref(m);
ret = proto_watch_write(pw, m, seq, 0);
proto_watch_unref(pw);
AQUIRE_LOCK(sinker->lock);
return ret;
}
mb = rtp_msg_to_interleaved_mb(m, ns->stms[stm_i].interleaved);
if (mb)
{
MEMBLOCK_SET_SEQ(mb, seq);
if (rs->trans_mode == RTP_OVER_TCP)
{
BUG_ON(!pw);
proto_watch_ref(pw);
RELEASE_LOCK(sinker->lock);
msg_ref(m);
ret = proto_watch_write_mb(pw, mb, 0);
proto_watch_unref(pw);
AQUIRE_LOCK(sinker->lock);
}
else
{
BUG_ON(!nc);
RELEASE_LOCK(ms->lock);
msg_ref(m);
ret = network_client_send_mb(nc, mb, 0);
AQUIRE_LOCK(ms->lock);
}
}
return ret;
}
示例5: ldl_op_fuck
static void
ldl_op_fuck(void *data, void *user_data)
{
int32_t err;
media_info msi;
tp_block *tb = (tp_block*)data;
ldl_src *ldl = (ldl_src*)tb->ls;
switch (tb->action)
{
case ACTION_PROBE:
media_info_init(&msi);
err = __ldl_src_probe(ldl, &tb->mrl, &msi);
media_src_fill_info((media_src*)ldl, &msi, err);
media_info_clear(&msi);
#ifdef DEVICE_INTERFACE_TEST
void ldl_interfaces_test(media_uri *mrl);
ldl_interfaces_test(&tb->mrl);
#endif
break;
case ACTION_OPEN:
AQUIRE_LOCK(ldl->ldl_lock);
err = __ldl_src_open(ldl, &tb->mrl);
RELEASE_LOCK(ldl->ldl_lock);
media_src_open_end((media_src*)ldl, err);
break;
case ACTION_PLAY:
AQUIRE_LOCK(ldl->ldl_lock);
__ldl_src_play(ldl);
RELEASE_LOCK(ldl->ldl_lock);
break;
case ACTION_CTRL:
AQUIRE_LOCK(ldl->ldl_lock);
__ldl_src_ctrl(ldl, 1, NULL);
RELEASE_LOCK(ldl->ldl_lock);
break;
case ACTION_CLOSE:
AQUIRE_LOCK(ldl->ldl_lock);
__ldl_src_kill(ldl);
RELEASE_LOCK(ldl->ldl_lock);
break;
default:
break;
}
media_src_unref((media_src*)ldl);
tr_free(tb, sizeof(*tb));
}
示例6: SrvCheckAndReferenceEndpoint
BOOLEAN SRVFASTCALL
SrvCheckAndReferenceEndpoint (
PENDPOINT Endpoint
)
/*++
Routine Description:
This function atomically verifies that an endpoint is active and
increments the reference count on the endpoint if it is.
Arguments:
Endpoint - Address of endpoint
Return Value:
BOOLEAN - Returns TRUE if the endpoint is active, FALSE otherwise.
--*/
{
PAGED_CODE( );
//
// Acquire the lock that guards the endpoint's state field.
//
ACQUIRE_LOCK( &SrvEndpointLock );
//
// If the endpoint is active, reference it and return TRUE.
//
if ( GET_BLOCK_STATE(Endpoint) == BlockStateActive ) {
SrvReferenceEndpoint( Endpoint );
RELEASE_LOCK( &SrvEndpointLock );
return TRUE;
}
//
// The endpoint isn't active. Return FALSE.
//
RELEASE_LOCK( &SrvEndpointLock );
return FALSE;
} // SrvCheckAndReferenceEndpoint
示例7: send
/*---------------------------------------------------------------------------*/
static int
send(const void *payload, unsigned short payload_len)
{
int res = 0;
GET_LOCK();
cc2520ll_prepare(payload, payload_len);
RELEASE_LOCK();
GET_LOCK();
res = cc2520ll_transmit();
RELEASE_LOCK();
return res;
}
示例8: cc2520_prepare
/*---------------------------------------------------------------------------*/
static int
cc2520_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
GET_LOCK();
PRINTF("cc2520: sending %d bytes\n", payload_len);
/*int i;
for(i = 0; i < payload_len;i++)
printf("%x",((uint8_t *) payload)[i]);
printf("\n");*/
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2520_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2520_INS_SFLUSHTX);
total_len = payload_len + FOOTER_LEN;
CC2520_WRITE_FIFO_BUF(&total_len, 1);
CC2520_WRITE_FIFO_BUF(payload, payload_len);
RELEASE_LOCK();
return 0;
}
示例9: cc2420_set_channel
/*---------------------------------------------------------------------------*/
int
cc2420_set_channel(int c)
{
uint16_t f;
GET_LOCK();
/*
* Subtract the base channel (11), multiply by 5, which is the
* channel spacing. 357 is 2405-2048 and 0x4000 is LOCK_THR = 1.
*/
channel = c;
f = 5 * (c - 11) + 357 + 0x4000;
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL((status() & (BV(CC2420_XOSC16M_STABLE))), RTIMER_SECOND / 10);
/* Wait for any transmission to end. */
BUSYWAIT_UNTIL(!(status() & BV(CC2420_TX_ACTIVE)), RTIMER_SECOND / 10);
setreg(CC2420_FSCTRL, f);
/* If we are in receive mode, we issue an SRXON command to ensure
that the VCO is calibrated. */
if(receive_on) {
strobe(CC2420_SRXON);
}
RELEASE_LOCK();
return 1;
}
示例10: cc2420_prepare
/*---------------------------------------------------------------------------*/
static int
cc2420_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
#if CC2420_CONF_CHECKSUM
uint16_t checksum;
#endif /* CC2420_CONF_CHECKSUM */
GET_LOCK();
PRINTF("cc2420: sending %d bytes\n", payload_len);
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2420_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2420_SFLUSHTX);
#if CC2420_CONF_CHECKSUM
checksum = crc16_data(payload, payload_len, 0);
#endif /* CC2420_CONF_CHECKSUM */
total_len = payload_len + AUX_LEN;
CC2420_WRITE_FIFO_BUF(&total_len, 1);
CC2420_WRITE_FIFO_BUF(payload, payload_len);
#if CC2420_CONF_CHECKSUM
CC2420_WRITE_FIFO_BUF(&checksum, CHECKSUM_LEN);
#endif /* CC2420_CONF_CHECKSUM */
RELEASE_LOCK();
return 0;
}
示例11: stopTicker
/* There may be at most one additional tick fired after a call to this */
void
stopTicker(void)
{
ACQUIRE_LOCK(&mutex);
stopped = 1;
RELEASE_LOCK(&mutex);
}
示例12: cc2520_rssi
/*---------------------------------------------------------------------------*/
int
cc2520_rssi(void)
{
int rssi;
int radio_was_off = 0;
if(locked) {
return 0;
}
GET_LOCK();
if(!receive_on) {
radio_was_off = 1;
cc2520_on();
}
BUSYWAIT_UNTIL(status() & BV(CC2520_RSSI_VALID), RTIMER_SECOND / 100);
rssi = (int)((signed char)getreg(CC2520_RSSI));
if(radio_was_off) {
cc2520_off();
}
RELEASE_LOCK();
return rssi;
}
示例13: cc2520_set_pan_addr
/*---------------------------------------------------------------------------*/
void
cc2520_set_pan_addr(unsigned pan,
unsigned addr,
const uint8_t *ieee_addr)
{
uint8_t tmp[2];
GET_LOCK();
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL(status() & (BV(CC2520_XOSC16M_STABLE)), RTIMER_SECOND / 10);
tmp[0] = pan & 0xff;
tmp[1] = pan >> 8;
CC2520_WRITE_RAM(&tmp, CC2520RAM_PANID, 2);
tmp[0] = addr & 0xff;
tmp[1] = addr >> 8;
CC2520_WRITE_RAM(&tmp, CC2520RAM_SHORTADDR, 2);
if(ieee_addr != NULL) {
int f;
uint8_t tmp_addr[8];
// LSB first, MSB last for 802.15.4 addresses in CC2520
for (f = 0; f < 8; f++) {
tmp_addr[7 - f] = ieee_addr[f];
}
CC2520_WRITE_RAM(tmp_addr, CC2520RAM_IEEEADDR, 8);
}
RELEASE_LOCK();
}
示例14: freeTaskManager
nat
freeTaskManager (void)
{
Task *task, *next;
nat tasksRunning = 0;
ACQUIRE_LOCK(&all_tasks_mutex);
for (task = all_tasks; task != NULL; task = next) {
next = task->all_next;
if (task->stopped) {
freeTask(task);
} else {
tasksRunning++;
}
}
debugTrace(DEBUG_sched, "freeing task manager, %d tasks still running",
tasksRunning);
all_tasks = NULL;
RELEASE_LOCK(&all_tasks_mutex);
#if defined(THREADED_RTS)
closeMutex(&all_tasks_mutex);
#if !defined(MYTASK_USE_TLV)
freeThreadLocalKey(¤tTaskKey);
#endif
#endif
tasksInitialized = 0;
return tasksRunning;
}
示例15: traceCapEvent_
void traceCapEvent_ (Capability *cap,
EventTypeNum tag)
{
#ifdef DEBUG
if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
ACQUIRE_LOCK(&trace_utx);
tracePreface();
switch (tag) {
case EVENT_CAP_CREATE: // (cap)
debugBelch("cap %d: initialised\n", cap->no);
break;
case EVENT_CAP_DELETE: // (cap)
debugBelch("cap %d: shutting down\n", cap->no);
break;
case EVENT_CAP_ENABLE: // (cap)
debugBelch("cap %d: enabling capability\n", cap->no);
break;
case EVENT_CAP_DISABLE: // (cap)
debugBelch("cap %d: disabling capability\n", cap->no);
break;
}
RELEASE_LOCK(&trace_utx);
} else
#endif
{
if (eventlog_enabled) {
postCapEvent(tag, (EventCapNo)cap->no);
}
}
}