summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authoraiju <aiju@phicode.de>2011-08-20 12:30:06 +0200
committeraiju <aiju@phicode.de>2011-08-20 12:30:06 +0200
commit8434f98cdda98c5463ccc3ba89feeeda064e873c (patch)
tree2cc45651702f284b77c1c5a99ef248c1e409cf67 /sys
parent0a0435dbc128705e1e4e3c1e2d45f686485d1dcd (diff)
added interrupt proc ctl message
Diffstat (limited to 'sys')
-rw-r--r--sys/include/9p.h2
-rw-r--r--sys/src/9/port/devproc.c13
-rw-r--r--sys/src/9/port/proc.c4
-rw-r--r--sys/src/lib9p/queue.c28
4 files changed, 36 insertions, 11 deletions
diff --git a/sys/include/9p.h b/sys/include/9p.h
index 5674a347c..6cac480fb 100644
--- a/sys/include/9p.h
+++ b/sys/include/9p.h
@@ -44,7 +44,7 @@ struct Reqqueue
QLock;
Rendez;
Queueelem;
- int pid;
+ int pid, flush;
Req *cur;
};
diff --git a/sys/src/9/port/devproc.c b/sys/src/9/port/devproc.c
index ed80e63e9..90e0f1cbb 100644
--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -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)
diff --git a/sys/src/9/port/proc.c b/sys/src/9/port/proc.c
index 25e84cd2c..fb7e6366a 100644
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -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;
diff --git a/sys/src/lib9p/queue.c b/sys/src/lib9p/queue.c
index d77d4552e..c0b52f94e 100644
--- a/sys/src/lib9p/queue.c
+++ b/sys/src/lib9p/queue.c
@@ -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){