]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/syscall_subr.c
xnu-1504.9.37.tar.gz
[apple/xnu.git] / osfmk / kern / syscall_subr.c
index f7855e11422dadc35fa4d7e1aa113d4d75c7231e..3daf1ec3874eccb8884bcb60508ff74ba14ffe8b 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2000-2007 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 #include <mach/mach_host_server.h>
 #include <mach/mach_syscalls.h>
 
 #include <mach/mach_host_server.h>
 #include <mach/mach_syscalls.h>
 
+
+#ifdef MACH_BSD
+extern void workqueue_thread_yielded(void);
+#endif /* MACH_BSD */
+
+
+/* Called from commpage to take a delayed preemption when exiting
+ * the "Preemption Free Zone" (PFZ).
+ */
+kern_return_t
+pfz_exit(
+__unused       struct pfz_exit_args *args)
+{
+       /* For now, nothing special to do.  We'll pick up the ASTs on kernel exit. */
+
+       return (KERN_SUCCESS);
+}
+
+
 /*
  *     swtch and swtch_pri both attempt to context switch (logic in
  *     thread_block no-ops the context switch if nothing would happen).
 /*
  *     swtch and swtch_pri both attempt to context switch (logic in
  *     thread_block no-ops the context switch if nothing would happen).
@@ -221,6 +240,8 @@ thread_switch(
            return (KERN_INVALID_ARGUMENT);
     }
 
            return (KERN_INVALID_ARGUMENT);
     }
 
+    workqueue_thread_yielded();
+
        /*
         * Translate the port name if supplied.
         */
        /*
         * Translate the port name if supplied.
         */
@@ -331,7 +352,6 @@ thread_depress_abstime(
 
                self->sched_pri = DEPRESSPRI;
                myprocessor->current_pri = self->sched_pri;
 
                self->sched_pri = DEPRESSPRI;
                myprocessor->current_pri = self->sched_pri;
-               self->sched_mode &= ~TH_MODE_PREEMPT;
                self->sched_mode |= TH_MODE_DEPRESS;
 
                if (interval != 0) {
                self->sched_mode |= TH_MODE_DEPRESS;
 
                if (interval != 0) {
@@ -427,7 +447,6 @@ thread_poll_yield(
                        if (!(self->sched_mode & TH_MODE_ISDEPRESSED)) {
                                self->sched_pri = DEPRESSPRI;
                                myprocessor->current_pri = self->sched_pri;
                        if (!(self->sched_mode & TH_MODE_ISDEPRESSED)) {
                                self->sched_pri = DEPRESSPRI;
                                myprocessor->current_pri = self->sched_pri;
-                               self->sched_mode &= ~TH_MODE_PREEMPT;
                        }
                        self->computation_epoch = abstime;
                        self->computation_metered = 0;
                        }
                        self->computation_epoch = abstime;
                        self->computation_metered = 0;
@@ -438,7 +457,7 @@ thread_poll_yield(
                                self->depress_timer_active++;
                        thread_unlock(self);
 
                                self->depress_timer_active++;
                        thread_unlock(self);
 
-                       if ((preempt = csw_check(self, myprocessor)) != AST_NONE)
+                       if ((preempt = csw_check(myprocessor)) != AST_NONE)
                                ast_on(preempt);
                }
        }
                                ast_on(preempt);
                }
        }