sync deputy and remote before processing request
Stephan Schmid <stephan_2303-S0/[email protected]>
| Newsgroups | gmane.linux.cluster.openmosix.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello I made a patch that makes deputy and remote sync if they issue both a request. The request of remote is processed first. Before returning to usermode remote should process the request of deputy, which issues the request again. This should happen in remote_pre_usermode, but I think the request hasnt yet arrived on remote when it is executed. I there a technique to suspend the remote process until something comes through the connection ? After all my tests I think this problem doesnt cause race conditions but sometimes it needs five minutes or so until a deputy request is processed (when there are lots of requests). Signal delivery kills the process. loop.c which was sent over the mailing list some time ago worked fine. A program which did permanently fopen(), fseek() and fclose() system calls needed usually a while to migrate back if the request was issued from deputy. Greetings Stephan Schmid ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ openMosix-devel mailing list openMosix-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/openmosix-devel
patch010801
(text/plain, 7.1 KB)
diff -rud temp5/hpc/comm.c workom/hpc/comm.c
--- temp5/hpc/comm.c 2006-07-23 12:02:02.000000000 +0200
+++ workom/hpc/comm.c 2006-07-31 20:12:09.000000000 +0200
@@ -522,9 +522,65 @@
}
-int comm_send_req(struct socket *link, int type)
+int comm_send_req_deputy(struct socket *link, int type)
{
struct omp_req req;
+ struct omp_req rreq;
+ int err;
req.type = type;
- return comm_send(link, &req, sizeof(req));
+start:
+ err = comm_send(link, &req, sizeof(req));
+ if (err <0) return err;
+ err = comm_recv(link, &rreq, sizeof(rreq));
+ if (err <0) return err;
+ if (rreq.type != (req.type | REPLY))
+ {
+ struct omp_req treq;
+ treq.type = rreq.type | REPLY;
+ err = comm_send(link, & treq, sizeof(treq));
+ if (err <0) return err;
+ __deputy_process_communication(current,rreq);
+ goto start;
+ }
+ return 0;
+}
+
+int comm_send_req_remote(struct socket *link, int type)
+{
+ struct omp_req req;
+ struct omp_req rreq;
+ int err;
+ req.type = type;
+
+ err = comm_send(link, &req, sizeof(req));
+ if (err <0) return err;
+ err = comm_recv(link, &rreq, sizeof(rreq));
+ if (err <0) return err;
+ if (rreq.type != (req.type | REPLY))
+ {
+ task_set_dflags(current, DDREQPENDING);
+ OMDEBUG(4,"registered deputy req");
+ err = comm_recv(link, &rreq, sizeof(rreq));
+ if (rreq.type != (req.type | REPLY)) return -1;
+ }
+ return 0;
+}
+
+int comm_recv_req(struct socket *link, struct omp_req * dest)
+{
+ struct omp_req rreq;
+ int err;
+ err= comm_recv(link, dest, sizeof(rreq));
+ if (err <0) return err;
+ rreq.type = dest->type | REPLY;
+ err= comm_send(link, &rreq, sizeof(rreq));
+ if (err <0) return err;
+ return 0;
}
+
+int comm_send_req(struct socket *link, int type) //this is without sync
+{
+ struct omp_req req;
+ req.type = type;
+ return comm_send(link, &req, sizeof(req));
+}
\ Kein Zeilenumbruch am Dateiende.
Nur in workom/hpc: comm.c~.
diff -rud temp5/hpc/deputy.c workom/hpc/deputy.c
--- temp5/hpc/deputy.c 2006-07-23 12:02:02.000000000 +0200
+++ workom/hpc/deputy.c 2006-07-30 14:25:34.000000000 +0200
@@ -45,8 +45,16 @@
{
struct omp_syscall_req s;
struct omp_syscall_ret r;
+ struct omp_req req;
int error;
+ error = comm_recv(p->om.contact, &req,sizeof(req));
+ if (error <0) return -1;
+ if (req.dlen != sizeof(s))
+ {
+ OMBUG("received %d instead of %d (sizeof(omp_syscall_req)), aborting syscall processing", req.dlen, sizeof(s));
+ return -1;
+ }
error = comm_recv(p->om.contact, &s, sizeof(s));
if (error < 0)
return -1;
@@ -416,15 +424,9 @@
/**
* deputy_process_communication - process has receive communication in deputy
**/
-static void deputy_process_communication(task_t *p)
+void __deputy_process_communication(task_t *p, struct omp_req req)
{
- struct omp_req req;
int error;
-
- error = comm_recv(p->om.contact, &req, sizeof(req));
- if (error < 0)
- deputy_die_on_communication();
-
switch (req.type)
{
case 0:
@@ -456,6 +458,18 @@
deputy_die_on_communication();
}
+static void deputy_process_communication(task_t *p)
+{
+ struct omp_req req;
+ int error;
+
+ error = comm_recv_req(p->om.contact, &req);
+ if (error < 0)
+ deputy_die_on_communication();
+
+ __deputy_process_communication(p,req);
+}
+
/**
* deputy_main_loop - process loop when process is deputy
**/
Nur in workom/hpc: deputy.c~.
diff -rud temp5/hpc/kernel.c workom/hpc/kernel.c
--- temp5/hpc/kernel.c 2006-07-23 12:02:02.000000000 +0200
+++ workom/hpc/kernel.c 2006-07-31 18:25:59.000000000 +0200
@@ -159,6 +159,11 @@
{
task_t *p = current;
+ if(task_test_dflags(p,DDREQPENDING))
+ {
+ task_clear_dflags(p,DDREQPENDING);
+ remote_do_comm(p);
+ }
if (p->om.contact && comm_peek(p->om.contact))
remote_do_comm(p);
return 0;
Nur in workom/hpc: kernel.c~.
diff -rud temp5/hpc/migctrl.c workom/hpc/migctrl.c
--- temp5/hpc/migctrl.c 2006-07-23 12:02:02.000000000 +0200
+++ workom/hpc/migctrl.c 2006-07-29 12:12:58.000000000 +0200
@@ -66,9 +66,9 @@
int error;
struct omp_req req;
- comm_send_req(p->om.contact, REM_BRING_HOME);
+ comm_send_req_remote(p->om.contact, REM_BRING_HOME);
- error = comm_recv(p->om.contact, &req, sizeof(req));
+ error = comm_recv_req(p->om.contact, &req);
if (error < 0)
return -1;
if (req.type != DEP_COMING_HOME) {
@@ -144,7 +144,7 @@
}
/* send remote request */
- comm_send_req(p->om.contact, DEP_COMING_HOME);
+ comm_send_req_deputy(p->om.contact, DEP_COMING_HOME);
/* see if other part is with on this */
if (mig_recv_hshake(p->om.contact))
Nur in workom/hpc: migctrl.c~.
diff -rud temp5/hpc/remote.c workom/hpc/remote.c
--- temp5/hpc/remote.c 2006-07-23 12:02:02.000000000 +0200
+++ workom/hpc/remote.c 2006-07-31 16:36:15.000000000 +0200
@@ -173,7 +173,7 @@
int error;
struct omp_req req;
- error = comm_recv(p->om.contact, &req, sizeof(req));
+ error = comm_recv_req(p->om.contact, &req);
if (error < 0)
goto fail;
@@ -214,7 +214,11 @@
s.n = n;
for (i = 0; i < NR_MAX_SYSCALL_ARG; i++)
s.arg[i] = arch_get_sys_arg(i, regs);
+ error = comm_send_req_remote(p->om.contact, REM_SYSCALL);
+ if (error < 0)
+ goto error;
+ OMDEBUG_SYS(3, "[remote] sysc. adv. sent, sending sysc_req");
error = comm_send_hd(p->om.contact, REM_SYSCALL, &s, sizeof(s));
if (error < 0)
goto error;
Nur in workom/hpc: remote.c~.
diff -rud temp5/include/hpc/comm.h workom/include/hpc/comm.h
--- temp5/include/hpc/comm.h 2006-07-23 12:02:02.000000000 +0200
+++ workom/include/hpc/comm.h 2006-07-29 12:47:26.000000000 +0200
@@ -61,7 +61,10 @@
struct socket * comm_setup_listen(struct sockaddr *);
struct socket * comm_setup_connect(struct sockaddr *, int);
int comm_send_hd(struct socket *, int, void *, int);
-int comm_send_req(struct socket *link, int type);
+int comm_send_req_deputy(struct socket *link, int type); //processes pending request from remote before
+int comm_send_req_remote(struct socket *link, int type);
+int comm_send_req(struct socket *link, int type);//without sync
+int comm_recv_req(struct socket *link, struct omp_req * dest);
/* FIXME: oM task routines, this really should be in task.h,
* but it causes problems there */
Nur in workom/include/hpc: comm.h~.
diff -rud temp5/include/hpc/prototype.h workom/include/hpc/prototype.h
--- temp5/include/hpc/prototype.h 2006-07-23 12:02:02.000000000 +0200
+++ workom/include/hpc/prototype.h 2006-07-29 12:46:51.000000000 +0200
@@ -32,6 +32,7 @@
NORET_TYPE void deputy_die_on_communication(void);
void deputy_main_loop(void);
void deputy_startup(task_t *p);
+void __deputy_process_communication(task_t *p, struct omp_req req); //used in comm.c (comm_send_req_deputy)
/*****************************************************************************/
Nur in workom/include/hpc: prototype.h~.
diff -rud temp5/include/hpc/task.h workom/include/hpc/task.h
--- temp5/include/hpc/task.h 2006-07-23 12:02:02.000000000 +0200
+++ workom/include/hpc/task.h 2006-07-31 18:15:20.000000000 +0200
@@ -49,6 +49,10 @@
#define DMIGRATED (DDEPUTY | DREMOTE) /* if task has been migrated */
+#define DDREQPENDING 0x00000800 /*deputy request pending set if\
+ comm_send_req_remote discovers a req.\
+ It is cleared by remote_pre_usermode*/
+
/*
* distributed request (dreqs):
* Thoses flags are set by any process to interact with the process.
Nur in workom/include/hpc: task.h~.