added interrupt proc ctl message

This commit is contained in:
aiju 2011-08-20 12:30:06 +02:00
parent 0a0435dbc1
commit 8434f98cdd
4 changed files with 36 additions and 11 deletions

View file

@ -44,7 +44,7 @@ struct Reqqueue
QLock;
Rendez;
Queueelem;
int pid;
int pid, flush;
Req *cur;
};

View file

@ -53,6 +53,8 @@ enum
CMwaitstop,
CMwired,
CMtrace,
CMinterrupt,
CMnointerrupt,
/* real time */
CMperiod,
CMdeadline,
@ -118,6 +120,8 @@ Cmdtab proccmd[] = {
CMwaitstop, "waitstop", 1,
CMwired, "wired", 2,
CMtrace, "trace", 0,
CMinterrupt, "interrupt", 1,
CMnointerrupt, "nointerrupt", 1,
CMperiod, "period", 2,
CMdeadline, "deadline", 2,
CMcost, "cost", 2,
@ -1414,6 +1418,15 @@ procctlreq(Proc *p, char *va, int n)
error("args");
}
break;
case CMinterrupt:
postnote(p, 0, nil, NUser);
break;
case CMnointerrupt:
if(p->nnote == 0)
p->notepending = 0;
else
error("notes pending");
break;
/* real time */
case CMperiod:
if(p->edf == nil)

View file

@ -904,11 +904,11 @@ postnote(Proc *p, int dolock, char *n, int flag)
if(dolock)
qlock(&p->debug);
if(flag != NUser && (p->notify == 0 || p->notified))
if(n != nil && flag != NUser && (p->notify == 0 || p->notified))
p->nnote = 0;
ret = 0;
if(p->nnote < NNOTE) {
if(p->nnote < NNOTE && n != nil) {
strcpy(p->note[p->nnote].msg, n);
p->note[p->nnote++].flag = flag;
ret = 1;

View file

@ -4,24 +4,27 @@
#include <fcall.h>
#include <9p.h>
static int
_reqqueuenote(void *, char *note)
{
return strcmp(note, "flush") == 0;
}
static void
_reqqueueproc(void *v)
{
Reqqueue *q;
Req *r;
void (*f)(Req *);
int fd;
char *buf;
q = v;
rfork(RFNOTEG);
threadnotify(_reqqueuenote, 1);
buf = smprint("/proc/%d/ctl", getpid());
fd = open(buf, OWRITE);
free(buf);
for(;;){
qlock(q);
q->flush = 0;
if(fd >= 0)
write(fd, "nointerrupt", 11);
q->cur = nil;
while(q->next == q)
rsleep(q);
@ -65,9 +68,18 @@ reqqueuepush(Reqqueue *q, Req *r, void (*f)(Req *))
void
reqqueueflush(Reqqueue *q, Req *r)
{
char buf[128];
int fd;
qlock(q);
if(q->cur == r){
postnote(PNPROC, q->pid, "flush");
sprint(buf, "/proc/%d/ctl", q->pid);
fd = open(buf, OWRITE);
if(fd >= 0){
write(fd, "interrupt", 9);
close(fd);
}
q->flush++;
qunlock(q);
}else{
if(r->qu.next != nil){