本文整理汇总了C++中spinlock_init函数的典型用法代码示例。如果您正苦于以下问题:C++ spinlock_init函数的具体用法?C++ spinlock_init怎么用?C++ spinlock_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spinlock_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spinlock_init
/*
* udp_instance_alloc()
*/
struct udp_instance *udp_instance_alloc(struct ip_instance *ii)
{
struct udp_instance *ui;
struct ip_client *ic;
ui = (struct udp_instance *)membuf_alloc(sizeof(struct udp_instance), NULL);
ui->ui_client_attach = udp_client_attach;
ui->ui_client_detach = udp_client_detach;
ui->ui_client_list = NULL;
spinlock_init(&ui->ui_lock, 0x24);
/*
* Attach this protocol handler to the IP stack.
*/
ic = ip_client_alloc();
ic->ic_protocol = 0x11;
ic->ic_recv = udp_recv_netbuf;
ic->ic_recv_icmp = NULL;
ic->ic_instance = ui;
udp_instance_ref(ui);
ui->ui_server = ii->ii_ip_client_attach(ii, ic);
ip_client_deref(ic);
return ui;
}
示例2: sem_create
struct semaphore *
sem_create(const char *name, int initial_count)
{
struct semaphore *sem;
KASSERT(initial_count >= 0);
sem = kmalloc(sizeof(struct semaphore));
if (sem == NULL) {
return NULL;
}
sem->sem_name = kstrdup(name);
if (sem->sem_name == NULL) {
kfree(sem);
return NULL;
}
sem->sem_wchan = wchan_create(sem->sem_name);
if (sem->sem_wchan == NULL) {
kfree(sem->sem_name);
kfree(sem);
return NULL;
}
spinlock_init(&sem->sem_lock);
sem->sem_count = initial_count;
return sem;
}
示例3: vn_initialize
struct vnode *
vn_initialize(
struct inode *inode)
{
struct vnode *vp = LINVFS_GET_VP(inode);
XFS_STATS_INC(vn_active);
XFS_STATS_INC(vn_alloc);
vp->v_flag = VMODIFIED;
spinlock_init(&vp->v_lock, "v_lock");
spin_lock(&vnumber_lock);
if (!++vn_generation) /* v_number shouldn't be zero */
vn_generation++;
vp->v_number = vn_generation;
spin_unlock(&vnumber_lock);
ASSERT(VN_CACHED(vp) == 0);
/* Initialize the first behavior and the behavior chain head. */
vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
#ifdef XFS_VNODE_TRACE
vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
#endif /* XFS_VNODE_TRACE */
vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
return vp;
}
示例4: tprintf_init
void tprintf_init(void)
{
spinlock_init(&buffer_lock);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
}
示例5: lock_create
struct lock *
lock_create(const char *name)
{
struct lock *lock;
lock = kmalloc(sizeof(struct lock));
if (lock == NULL) {
return NULL;
}
lock->lk_name = kstrdup(name);
if (lock->lk_name == NULL) {
kfree(lock);
return NULL;
}
#if OPT_A1
lock->lock_wchan = wchan_create(lock->lk_name);
if (lock->lock_wchan == NULL) {
kfree(lock->lk_name);
kfree(lock);
}
spinlock_init(&lock->lk_spinlock);
lock->available = true;
#endif
return lock;
}
示例6: ModuleInit
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise debug CLI router module %s.", version_str);
spinlock_init(&instlock);
instances = NULL;
}
示例7: id_gen_test
int id_gen_test(int nargs, char **args){
sem_numthread = sem_create("sem_testidgen",0);
struct spinlock splock;
spinlock_init(&splock);
idgen = idgen_create(0);
KASSERT(idgen != NULL);
(void)nargs;
(void)args;
const int NUMTHREAD = 3;
int i = 0;
for (; i < NUMTHREAD; i++){
kprintf ("MAKING THREAD %d\n", i);
thread_fork("id_gen_test", NULL, test_generator, NULL, i);
}
for (int j = 0; j < NUMTHREAD; j++,i++){
kprintf ("MAKING THREAD %d\n", i);
thread_fork("id_gen_test", NULL, test_generator2, NULL, i);
}
for (int j = 0; j < 2*NUMTHREAD; j++){
P(sem_numthread);
}
idgen_destroy(idgen);
sem_destroy(sem_numthread);
return 0;
}
示例8: service_alloc
/**
* Allocate a new service for the gateway to support
*
*
* @param servname The service name
* @param router Name of the router module this service uses
*
* @return The newly created service or NULL if an error occured
*/
SERVICE *
service_alloc(char *servname, char *router)
{
SERVICE *service;
if ((service = (SERVICE *)malloc(sizeof(SERVICE))) == NULL)
return NULL;
if ((service->router = load_module(router, MODULE_ROUTER)) == NULL)
{
free(service);
return NULL;
}
service->name = strdup(servname);
service->routerModule = strdup(router);
memset(&service->stats, 0, sizeof(SERVICE_STATS));
service->ports = NULL;
service->stats.started = time(0);
service->state = SERVICE_STATE_ALLOC;
service->credentials.name = NULL;
service->credentials.authdata = NULL;
service->users = users_alloc();
service->enable_root = 0;
service->routerOptions = NULL;
service->databases = NULL;
spinlock_init(&service->spin);
spinlock_acquire(&service_spin);
service->next = allServices;
allServices = service;
spinlock_release(&service_spin);
return service;
}
示例9: cv_create
struct cv *
cv_create(const char *name)
{
struct cv *cv;
cv = kmalloc(sizeof(*cv));
if (cv == NULL) {
return NULL;
}
cv->cv_name = kstrdup(name);
if (cv->cv_name==NULL) {
kfree(cv);
return NULL;
}
cv->cv_wchan = wchan_create(cv->cv_name);
if (cv->cv_wchan == NULL) {
kfree(cv->cv_name);
kfree(cv);
return NULL;
}
spinlock_init(&cv->cv_spinlock);
// add stuff here as needed
return cv;
}
示例10: prepare_for_sleep
u32
prepare_for_sleep (u32 firmware_waking_vector)
{
u8 *p;
int wakeup_entry_len;
/* Get the suspend-lock to make other processors stopping or staying
in the guest mode. */
get_suspend_lock ();
/* Now the VMM is executed by the current processor only.
Call suspend functions. */
call_initfunc ("suspend");
/* Initialize variables used by wakeup functions */
wakeup_cpucount = 0;
spinlock_init (&wakeup_cpucount_lock);
waking_vector = firmware_waking_vector;
wakeup_prepare ();
/* Copy the wakeup_entry code. */
wakeup_entry_len = wakeup_entry_end - wakeup_entry_start;
p = mapmem_hphys (wakeup_entry_addr, wakeup_entry_len, MAPMEM_WRITE);
memcpy (p, wakeup_entry_start, wakeup_entry_len);
unmapmem (p, wakeup_entry_len);
return wakeup_entry_addr;
}
示例11: lock_create
struct lock *
lock_create(const char *name)
{
struct lock *lock;
lock = kmalloc(sizeof(*lock));
if (lock == NULL) {
return NULL;
}
lock->lk_name = kstrdup(name);
if (lock->lk_name == NULL) {
kfree(lock);
return NULL;
}
lock->lk_wchan = wchan_create(lock->lk_name);
if (lock->lk_wchan == NULL) {
kfree(lock->lk_name);
kfree(lock);
return NULL;
}
spinlock_init(&lock->lk_spinlock);
lock->lk_isheld = false;
lock->lk_curthread = NULL;
// add stuff here as needed
return lock;
}
示例12: lock_create
struct lock *
lock_create(const char *name)
{
struct lock *lock;
lock = kmalloc(sizeof(struct lock));
if (lock == NULL) {
return NULL;
}
lock->lk_name = kstrdup(name);
if (lock->lk_name == NULL) {
kfree(lock);
return NULL;
}
// add stuff here as needed
//Peng 2.19.2016
lock->lock_wchan = wchan_create(lock->lk_name);
if (lock->lock_wchan == NULL) {
kfree(lock->lk_name);
kfree(lock);
return NULL;
}
spinlock_init(&lock->lock_splk);
lock->held=false;
lock->holder=NULL;
//Peng
return lock;
}
示例13: hubspc_init
/*
* hubspc_init
* Registration of the hubspc devices with the hub manager
*/
void
hubspc_init(void)
{
/*
* Register with the hub manager
*/
/* The reference counters */
hubdev_register(mem_refcnt_attach);
/* Prom space */
hubdev_register(cpuprom_attach);
#if defined(CONFIG_SERIAL_SGI_L1_PROTOCOL)
/* L1 system controller link */
if ( !IS_RUNNING_ON_SIMULATOR() ) {
/* initialize the L1 link */
void l1_cons_init( l1sc_t *sc );
elsc_t *get_elsc(void);
l1_cons_init((l1sc_t *)get_elsc());
}
#endif
#ifdef HUBSPC_DEBUG
printf("hubspc_init: Completed\n");
#endif /* HUBSPC_DEBUG */
/* Initialize spinlocks */
spinlock_init(&cpuprom_spinlock, "promlist");
}
示例14: pro100_new
// 新しいデバイスの発見
void pro100_new(struct pci_device *dev)
{
PRO100_CTX *ctx = SeZeroMalloc(sizeof(PRO100_CTX));
debugprint ("pro100_new\n");
#ifdef VTD_TRANS
if (iommu_detected) {
add_remap(dev->address.bus_no ,dev->address.device_no ,dev->address.func_no,
vmm_start_inf() >> 12, (vmm_term_inf()-vmm_start_inf()) >> 12, PERM_DMA_RW) ;
}
#endif // of VTD_TRANS
ctx->dev = dev;
spinlock_init (&ctx->lock);
dev->host = ctx;
dev->driver->options.use_base_address_mask_emulation = 1;
pro100_alloc_recv_buffer(ctx);
if (pro100_ctx == NULL)
{
pro100_ctx = ctx;
}
else
{
debugprint("Error: Two or more pro100 devices found.\n");
pro100_beep(1234, 5000);
}
}
示例15: hashtable_alloc
/**
* Allocate a new hash table
*
* @param size The size of the hash table
* @param hashfn The user supplied hash function
* @param cmpfn The user supplied key comparison function
* @return The hashtable table
*/
HASHTABLE *
hashtable_alloc(int size, int (*hashfn)(), int (*cmpfn)())
{
HASHTABLE *rval;
if ((rval = malloc(sizeof(HASHTABLE))) == NULL)
return NULL;
#if defined(SS_DEBUG)
rval->ht_chk_top = CHK_NUM_HASHTABLE;
rval->ht_chk_tail = CHK_NUM_HASHTABLE;
#endif
rval->hashsize = size;
rval->hashfn = hashfn;
rval->cmpfn = cmpfn;
rval->kcopyfn = nullfn;
rval->vcopyfn = nullfn;
rval->kfreefn = nullfn;
rval->vfreefn = nullfn;
rval->n_readers = 0;
rval->writelock = 0;
spinlock_init(&rval->spin);
if ((rval->entries = (HASHENTRIES **)calloc(size, sizeof(HASHENTRIES *))) == NULL)
{
free(rval);
return NULL;
}
memset(rval->entries, 0, size * sizeof(HASHENTRIES *));
return rval;
}