]> git.corax.cc Git - corax/commitdiff
Fix some minor problems in the process implementation
authorMatthias Kruk <m@m10k.eu>
Sat, 25 Jan 2020 07:41:55 +0000 (16:41 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 25 Jan 2020 07:41:55 +0000 (16:41 +0900)
 - Don't lock tasks in process_task_foreach()
 - Wake up processes when they receive signals

kernel/core/process.c

index 9587e286cc736c11b9bbdd313e6c92c87be50f3a..72ac3e98e65772b18b643c6e1369cee276a62a8a 100644 (file)
@@ -1032,9 +1032,7 @@ int process_task_foreach(process_t *proc, int (*func)(process_t*, task_t*, void*
                        task_t *t = proc->p_tasks[i];
 
                        if(t) {
-                               task_lock(t);
                                ret_val = func(proc, t, data);
-                               task_unlock(t);
 
                                if(ret_val < 0) {
                                        break;
@@ -1131,6 +1129,8 @@ int process_put_signal(process_t *proc, int signal, siginfo_t *si)
        ret_val = -EINVAL;
 
        if(proc && signal >= 0 && signal <= SIGMAX) {
+               pid_t pid;
+
                ret_val = -EALREADY;
 
                process_lock(proc);
@@ -1144,12 +1144,16 @@ int process_put_signal(process_t *proc, int signal, siginfo_t *si)
                                memcpy(&(proc->p_siginfo), si, sizeof(proc->p_siginfo));
                        }
 
-                       /* process needs to be woken up if it was sleeping */
-
+                       pid = proc->p_id;
                        ret_val = 0;
                }
 
                process_unlock(proc);
+
+               if(!ret_val) {
+                       /* process needs to be woken up if it was sleeping */
+                       sched_raise(pid);
+               }
        }
 
        return(ret_val);