本文整理汇总了C++中qunlock函数的典型用法代码示例。如果您正苦于以下问题:C++ qunlock函数的具体用法?C++ qunlock怎么用?C++ qunlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qunlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: waitforkick
void
waitforkick(Round *r)
{
int n;
qlock(&r->lock);
r->last = r->current;
assert(r->current+1 == r->next);
rwakeupall(&r->finish);
while(!r->doanother)
rsleep(&r->start);
n = r->next++;
r->current = n;
r->doanother = 0;
qunlock(&r->lock);
}
示例2: unbreak
void
unbreak(Proc *p)
{
int b;
qlock(&broken);
for(b=0; b < broken.n; b++)
if(broken.p[b] == p) {
broken.n--;
memmove(&broken.p[b], &broken.p[b+1],
sizeof(Proc*)*(NBROKEN-(b+1)));
ready(p);
break;
}
qunlock(&broken);
}
示例3: putbuf
void
putbuf(Iobuf *p)
{
if(canqlock(p))
print("buffer not locked %Z(%lld)\n", p->dev, (Wideoff)p->addr);
if(p->flags & Bimm) {
if(!(p->flags & Bmod))
print("imm and no mod %Z(%lld)\n",
p->dev, (Wideoff)p->addr);
if(!devwrite(p->dev, p->addr, p->iobuf))
p->flags &= ~(Bmod|Bimm);
}
iobufunmap(p);
qunlock(p);
}
示例4: serve
/*
* main filesystem server loop.
* entered by many processes.
* they wait for message buffers and
* then process them.
*/
void
serve(void *)
{
int i;
Chan *cp;
Msgbuf *mb;
for (;;) {
qlock(&reflock);
/* read 9P request from a network input process */
mb = fs_recv(serveq, 0);
assert(mb->magic == Mbmagic);
/* fs kernel sets chan in /sys/src/fs/ip/il.c:/^getchan */
cp = mb->chan;
if (cp == nil)
panic("serve: nil mb->chan");
rlock(&cp->reflock);
qunlock(&reflock);
rlock(&mainlock);
if (mb->data == nil)
panic("serve: nil mb->data");
/* better sniffing code in /sys/src/cmd/disk/kfs/9p12.c */
if(cp->protocol == nil){
/* do we recognise the protocol in this packet? */
/* better sniffing code: /sys/src/cmd/disk/kfs/9p12.c */
for(i = 0; fsprotocol[i] != nil; i++)
if(fsprotocol[i](mb) != 0) {
cp->protocol = fsprotocol[i];
break;
}
if(cp->protocol == nil){
print("no protocol for message\n");
for(i = 0; i < 12; i++)
print(" %2.2X", mb->data[i]);
print("\n");
}
} else
/* process the request, generate an answer and reply */
cp->protocol(mb);
mbfree(mb);
runlock(&mainlock);
runlock(&cp->reflock);
}
}
示例5: iobufinit
/*
* allocate rest of mem
* for io buffers.
*/
#define HWIDTH 5 /* buffers per hash */
void
iobufinit(void)
{
int32_t i;
Iobuf *p, *q;
Hiob *hp;
i = conf.niobuf*RBUFSIZE;
niob = i / (sizeof(Iobuf) + RBUFSIZE + sizeof(Hiob)/HWIDTH);
nhiob = niob / HWIDTH;
while(!prime(nhiob))
nhiob++;
if(chat)
print(" %ld buffers; %ld hashes\n", niob, nhiob);
hiob = ialloc(nhiob * sizeof(Hiob));
hp = hiob;
for(i=0; i<nhiob; i++) {
lock(hp);
unlock(hp);
hp++;
}
p = ialloc(niob * sizeof(Iobuf));
hp = hiob;
for(i=0; i<niob; i++) {
qlock(p);
qunlock(p);
if(hp == hiob)
hp = hiob + nhiob;
hp--;
q = hp->link;
if(q) {
p->fore = q;
p->back = q->back;
q->back = p;
p->back->fore = p;
} else {
hp->link = p;
p->fore = p;
p->back = p;
}
p->dev = devnone;
p->addr = -1;
p->xiobuf = ialloc(RBUFSIZE);
p->iobuf = (char*)-1;
p++;
}
}
示例6: procalarm
ulong
procalarm(ulong time)
{
Proc **l, *f;
ulong when, old;
if(up->alarm)
old = tk2ms(up->alarm - MACHP(0)->ticks);
else
old = 0;
if(time == 0) {
up->alarm = 0;
return old;
}
when = ms2tk(time)+MACHP(0)->ticks;
qlock(&alarms);
l = &alarms.head;
for(f = *l; f; f = f->palarm) {
if(up == f){
*l = f->palarm;
break;
}
l = &f->palarm;
}
up->palarm = 0;
if(alarms.head) {
l = &alarms.head;
for(f = *l; f; f = f->palarm) {
if(f->alarm > when) {
up->palarm = f;
*l = up;
goto done;
}
l = &f->palarm;
}
*l = up;
}
else
alarms.head = up;
done:
up->alarm = when;
qunlock(&alarms);
return old;
}
示例7: pageouttext
static void
pageouttext(int pgszi, int color)
{
Proc *p;
Pgsza *pa;
int i, n, np, x;
Segment *s;
int prepaged;
USED(color);
pa = &pga.pgsza[pgszi];
n = x = 0;
prepaged = 0;
/*
* Try first to steal text pages from non-prepaged processes,
* then from anyone.
*/
Again:
do{
if((p = psincref(x)) == nil)
break;
np = 0;
if(p->prepagemem == 0 || prepaged != 0)
if(p->state != Dead && p->noswap == 0 && canqlock(&p->seglock)){
for(i = 0; i < NSEG; i++){
if((s = p->seg[i]) == nil)
continue;
if((s->type&SG_TYPE) == SG_TEXT)
np = pageout(p, s);
}
qunlock(&p->seglock);
}
/*
* else process dead or locked or changing its segments
*/
psdecref(p);
n += np;
if(np > 0)
DBG("pager: %d from proc #%d %#p\n", np, x, p);
x++;
}while(pa->freecount < Minpages);
if(pa->freecount < Minpages && prepaged++ == 0)
goto Again;
}
示例8: newfp
/*
* always called with cp->flock locked
*/
File*
newfp(Chan *cp)
{
File *f, *e;
retry:
lock(&suballoc.flock);
f = suballoc.ffree;
if(f != nil){
suballoc.ffree = f->list;
unlock(&suballoc.flock);
f->list = 0;
f->cp = cp;
f->next = cp->flist;
f->wpath = 0;
f->tlock = 0;
f->dslot = 0;
f->doffset = 0;
f->uid = 0;
f->cuid = 0;
cp->flist = f;
return f;
}
unlock(&suballoc.flock);
if(conf.nfile > Fmax){
print("%d: out of files\n", cp->chan);
return 0;
}
/*
* create a few new files
*/
f = malloc(Finc*sizeof(*f));
memset(f, 0, Finc*sizeof(*f));
lock(&suballoc.flock);
for(e = f+Finc; f < e; f++){
qlock(f);
qunlock(f);
f->list = suballoc.ffree;
suballoc.ffree = f;
}
conf.nfile += Finc;
unlock(&suballoc.flock);
goto retry;
}
示例9: cecattach
static Chan *
cecattach(char *spec)
{
Chan *c;
static QLock q;
static int inited;
qlock(&q);
if(inited == 0){
kproc("cectimer", cectimer, nil);
inited++;
}
qunlock(&q);
c = devattach(L'©', spec);
c->qid.path = Qdir;
return c;
}
示例10: loopbackwalk
static Walkqid*
loopbackwalk(Chan *c, Chan *nc, char **name, int nname)
{
Walkqid *wq;
Loop *lb;
wq = devwalk(c, nc, name, nname, nil, 0, loopbackgen);
if(wq != nil && wq->clone != nil && wq->clone != c){
lb = c->aux;
qlock(lb);
lb->ref++;
if((c->flag & COPEN) && TYPE(c->qid.path) == Qdata)
lb->link[ID(c->qid.path)].ref++;
qunlock(lb);
}
return wq;
}
示例11: addbroken
void
addbroken(Proc *p)
{
qlock(&broken);
if(broken.n == NBROKEN) {
ready(broken.p[0]);
memmove(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1));
--broken.n;
}
broken.p[broken.n++] = p;
qunlock(&broken);
edfstop(up);
p->state = Broken;
p->psstate = nil;
sched();
}
示例12: usbfsdirdump
void
usbfsdirdump(void)
{
int i;
qlock(&fslck);
fprint(2, "%s: fs list: (%d used %d total)\n", argv0, fsused, nfs);
for(i = 1; i < nfs; i++)
if(fs[i] != nil) {
if(fs[i]->dev != nil)
fprint(2, "%s\t%s dev %#p refs %ld\n",
argv0, fs[i]->name, fs[i]->dev, fs[i]->dev->Ref.ref);
else
fprint(2, "%s:\t%s\n", argv0, fs[i]->name);
}
qunlock(&fslck);
}
示例13: aoeinit
static void
aoeinit(void)
{
static int init;
static QLock l;
if(!canqlock(&l))
return;
if(init == 0){
fmtinstall(L'æ', fmtæ);
events.rp = events.wp = events.buf;
kproc("aoesweep", aoesweepproc, nil);
aoecfg();
init = 1;
}
qunlock(&l);
}
示例14: unionread
static int32_t
unionread(Chan *c, void *va, int32_t n)
{
Proc *up = externup();
int i;
int32_t nr;
Mhead *mh;
Mount *mount;
qlock(&c->umqlock);
mh = c->umh;
rlock(&mh->lock);
mount = mh->mount;
/* bring mount in sync with c->uri and c->umc */
for(i = 0; mount != nil && i < c->uri; i++)
mount = mount->next;
nr = 0;
while(mount != nil){
/* Error causes component of union to be skipped */
if(mount->to && !waserror()){
if(c->umc == nil){
c->umc = cclone(mount->to);
c->umc = c->umc->dev->open(c->umc, OREAD);
}
nr = c->umc->dev->read(c->umc, va, n, c->umc->offset);
c->umc->offset += nr;
poperror();
}
if(nr > 0)
break;
/* Advance to next element */
c->uri++;
if(c->umc){
cclose(c->umc);
c->umc = nil;
}
mount = mount->next;
}
runlock(&mh->lock);
qunlock(&c->umqlock);
return nr;
}
示例15: espadvise
/* called from icmp(v6) for unreachable hosts, time exceeded, etc. */
void
espadvise(Proto *esp, Block *bp, char *msg)
{
Conv *c;
Versdep vers;
getverslens(pktipvers(esp->f, &bp), &vers);
getpktspiaddrs(bp->rp, &vers);
qlock(esp);
c = convlookup(esp, vers.spi);
if(c != nil) {
qhangup(c->rq, msg);
qhangup(c->wq, msg);
}
qunlock(esp);
freeblist(bp);
}