added interrupt proc ctl message
This commit is contained in:
parent
0a0435dbc1
commit
8434f98cdd
4 changed files with 36 additions and 11 deletions
|
@ -44,7 +44,7 @@ struct Reqqueue
|
||||||
QLock;
|
QLock;
|
||||||
Rendez;
|
Rendez;
|
||||||
Queueelem;
|
Queueelem;
|
||||||
int pid;
|
int pid, flush;
|
||||||
Req *cur;
|
Req *cur;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ enum
|
||||||
CMwaitstop,
|
CMwaitstop,
|
||||||
CMwired,
|
CMwired,
|
||||||
CMtrace,
|
CMtrace,
|
||||||
|
CMinterrupt,
|
||||||
|
CMnointerrupt,
|
||||||
/* real time */
|
/* real time */
|
||||||
CMperiod,
|
CMperiod,
|
||||||
CMdeadline,
|
CMdeadline,
|
||||||
|
@ -118,6 +120,8 @@ Cmdtab proccmd[] = {
|
||||||
CMwaitstop, "waitstop", 1,
|
CMwaitstop, "waitstop", 1,
|
||||||
CMwired, "wired", 2,
|
CMwired, "wired", 2,
|
||||||
CMtrace, "trace", 0,
|
CMtrace, "trace", 0,
|
||||||
|
CMinterrupt, "interrupt", 1,
|
||||||
|
CMnointerrupt, "nointerrupt", 1,
|
||||||
CMperiod, "period", 2,
|
CMperiod, "period", 2,
|
||||||
CMdeadline, "deadline", 2,
|
CMdeadline, "deadline", 2,
|
||||||
CMcost, "cost", 2,
|
CMcost, "cost", 2,
|
||||||
|
@ -1414,6 +1418,15 @@ procctlreq(Proc *p, char *va, int n)
|
||||||
error("args");
|
error("args");
|
||||||
}
|
}
|
||||||
break;
|
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 */
|
/* real time */
|
||||||
case CMperiod:
|
case CMperiod:
|
||||||
if(p->edf == nil)
|
if(p->edf == nil)
|
||||||
|
|
|
@ -904,11 +904,11 @@ postnote(Proc *p, int dolock, char *n, int flag)
|
||||||
if(dolock)
|
if(dolock)
|
||||||
qlock(&p->debug);
|
qlock(&p->debug);
|
||||||
|
|
||||||
if(flag != NUser && (p->notify == 0 || p->notified))
|
if(n != nil && flag != NUser && (p->notify == 0 || p->notified))
|
||||||
p->nnote = 0;
|
p->nnote = 0;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if(p->nnote < NNOTE) {
|
if(p->nnote < NNOTE && n != nil) {
|
||||||
strcpy(p->note[p->nnote].msg, n);
|
strcpy(p->note[p->nnote].msg, n);
|
||||||
p->note[p->nnote++].flag = flag;
|
p->note[p->nnote++].flag = flag;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
|
@ -4,24 +4,27 @@
|
||||||
#include <fcall.h>
|
#include <fcall.h>
|
||||||
#include <9p.h>
|
#include <9p.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_reqqueuenote(void *, char *note)
|
|
||||||
{
|
|
||||||
return strcmp(note, "flush") == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_reqqueueproc(void *v)
|
_reqqueueproc(void *v)
|
||||||
{
|
{
|
||||||
Reqqueue *q;
|
Reqqueue *q;
|
||||||
Req *r;
|
Req *r;
|
||||||
void (*f)(Req *);
|
void (*f)(Req *);
|
||||||
|
int fd;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
q = v;
|
q = v;
|
||||||
rfork(RFNOTEG);
|
rfork(RFNOTEG);
|
||||||
threadnotify(_reqqueuenote, 1);
|
|
||||||
|
buf = smprint("/proc/%d/ctl", getpid());
|
||||||
|
fd = open(buf, OWRITE);
|
||||||
|
free(buf);
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
qlock(q);
|
qlock(q);
|
||||||
|
q->flush = 0;
|
||||||
|
if(fd >= 0)
|
||||||
|
write(fd, "nointerrupt", 11);
|
||||||
q->cur = nil;
|
q->cur = nil;
|
||||||
while(q->next == q)
|
while(q->next == q)
|
||||||
rsleep(q);
|
rsleep(q);
|
||||||
|
@ -65,9 +68,18 @@ reqqueuepush(Reqqueue *q, Req *r, void (*f)(Req *))
|
||||||
void
|
void
|
||||||
reqqueueflush(Reqqueue *q, Req *r)
|
reqqueueflush(Reqqueue *q, Req *r)
|
||||||
{
|
{
|
||||||
|
char buf[128];
|
||||||
|
int fd;
|
||||||
|
|
||||||
qlock(q);
|
qlock(q);
|
||||||
if(q->cur == r){
|
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);
|
qunlock(q);
|
||||||
}else{
|
}else{
|
||||||
if(r->qu.next != nil){
|
if(r->qu.next != nil){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue