[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] kernel: SYSCALL_FASTRPC_WAIT



+ kernel: SYSCALL_FASTRPC_WAIT als Kombination von RPC und wait_for_rpc()
* libc: Neuen Syscall fuer Sync-RPC benutzen
---
 src/include/syscallno.h        |    1 +
 src/kernel/src/syscall.c       |   10 ++++++++++
 src/modules/include/syscall.h  |    1 +
 src/modules/lib/rpc/sync.c     |    2 +-
 src/modules/lib/syscalls/rpc.c |   21 +++++++++++++++++----
 5 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/include/syscallno.h b/src/include/syscallno.h
index b56ad45..16786f3 100644
--- a/src/include/syscallno.h
+++ b/src/include/syscallno.h
@@ -76,6 +76,7 @@
 
 #define SYSCALL_FASTRPC 55
 #define SYSCALL_FASTRPC_RET 56
+#define SYSCALL_FASTRPC_WAIT 58
 
 #define SYSCALL_WAIT_FOR_RPC 57
 
diff --git a/src/kernel/src/syscall.c b/src/kernel/src/syscall.c
index 2ee793d..b2b11e0 100644
--- a/src/kernel/src/syscall.c
+++ b/src/kernel/src/syscall.c
@@ -657,6 +657,15 @@ void syscall(struct int_stack_frame ** esp)
             break;
         }
 
+        case SYSCALL_FASTRPC_WAIT:
+        {
+            dword callee_pid = *((dword*) isf->esp);
+
+            if (callee_pid != current_task->pid) {
+                current_task->status = TS_WAIT_FOR_RPC;
+            }
+        }
+            /* Fall-through */
         case SYSCALL_FASTRPC:
         {
             dword metadata_size = *((dword*) (isf->esp + 4));
@@ -693,6 +702,7 @@ void syscall(struct int_stack_frame ** esp)
             )) {
                 schedule_to_task(callee, (dword*) esp);
             } else {
+                current_task->status = TS_RUNNING;
                 isf->eax = -1;
                 schedule((dword*)esp);
             }
diff --git a/src/modules/include/syscall.h b/src/modules/include/syscall.h
index e22b0df..177b06c 100644
--- a/src/modules/include/syscall.h
+++ b/src/modules/include/syscall.h
@@ -73,6 +73,7 @@ void add_intr_handler(dword intr);
 
 void rpc(pid_t pid);
 void send_message(pid_t pid, dword function, dword correlation_id, dword len, char* data);
+void send_message_and_wait_for_rpc(pid_t pid, dword function, dword correlation_id, dword len, char* data);
 void wait_for_rpc(void);
 void v_and_wait_for_rpc(void);
 
diff --git a/src/modules/lib/rpc/sync.c b/src/modules/lib/rpc/sync.c
index 9c5bede..0f65fd7 100644
--- a/src/modules/lib/rpc/sync.c
+++ b/src/modules/lib/rpc/sync.c
@@ -174,7 +174,7 @@ static response_t* sync_rpc(pid_t pid, char* function_name, size_t data_length,
     // W�hrend dem RPC selbst nicht blockieren, da es sonst bei Self-RPC dazu
     // f�hrt, da� Code geblockt ist, der dazu nicht vorgesehen ist.
     v();
-    send_message(pid, 512, correlation_id, data_length + RPC_FUNCTION_NAME_LENGTH, rpc_data);
+    send_message_and_wait_for_rpc(pid, 512, correlation_id, data_length + RPC_FUNCTION_NAME_LENGTH, rpc_data);
     p();
 
     response_t* response;
diff --git a/src/modules/lib/syscalls/rpc.c b/src/modules/lib/syscalls/rpc.c
index 72d4bbc..68cb394 100644
--- a/src/modules/lib/syscalls/rpc.c
+++ b/src/modules/lib/syscalls/rpc.c
@@ -16,8 +16,9 @@ void rpc(dword pid)
     } while (result != 0);
 }
 
-void send_message
-    (dword pid, dword function, dword correlation_id, dword len, char* data)
+static inline void do_send_message
+    (dword pid, dword function, dword correlation_id, dword len, char* data,
+    bool wait_for_rpc)
 {
     dword result = 0;
 
@@ -38,10 +39,22 @@ void send_message
             "mov %1, %%eax;"
             "int $0x30;"
             "add $0x14, %%esp;"
-        : "=a" (result) 
-        : "i" (SYSCALL_FASTRPC), "g" (pid), "i" (0x8), "g" (metadata), 
+        : "=a" (result)
+        : "i" (wait_for_rpc ? SYSCALL_FASTRPC_WAIT : SYSCALL_FASTRPC),
+            "g" (pid), "i" (0x8), "g" (metadata),
             "g" (len), "g" (data), "0" (result));
 
     } while (result != 0);
 }
 
+void send_message
+    (dword pid, dword function, dword correlation_id, dword len, char* data)
+{
+    do_send_message(pid, function, correlation_id, len, data, FALSE);
+}
+
+void send_message_and_wait_for_rpc
+    (dword pid, dword function, dword correlation_id, dword len, char* data)
+{
+    do_send_message(pid, function, correlation_id, len, data, TRUE);
+}
-- 
1.5.6.5