Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149423586
D3390.id7966.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D3390.id7966.diff
View Options
Index: share/man/man9/kproc.9
===================================================================
--- share/man/man9/kproc.9
+++ share/man/man9/kproc.9
@@ -179,11 +179,12 @@
The
.Fa ecode
argument specifies the exit status of the process.
-While exiting, the function
-.Xr exit1 9
-will initiate a call to
-.Xr wakeup 9
-on the process handle.
+A
+.Fn wakeup
+is issued on the proc pointer which can be used by callers to know
+when the called function is no longer running.
+See the EXAMPLE section for how to use this to ensure that a module
+is unloaded safely.
.Pp
The
.Fn kproc_resume ,
@@ -321,6 +322,40 @@
}
}
.Ed
+.Pp
+When the process is started as part of a module, the module needs to ensure
+that the module's code is no longer executing.
+.Bd -literal -offset indent
+struct mtx proc_interlock;
+volatile int proc_intervar;
+struct proc *procptr; /* prointer from kproc_create */
+
+void
+kproc_fun(void *arg)
+{
+
+ for (;;) {
+ mtx_lock(&proc_interlock);
+ if (proc_intervar)
+ break;
+ mtx_unlock(&proc_interlock);
+
+ /* do work */
+ }
+
+ kproc_exit(0);
+}
+
+void
+unloadmod(void)
+{
+
+ mtx_lock(&proc_interlock);
+ proc_intervar = 1;
+ mtx_sleep(procptr, &proc_interlock, PDROP, "procexit", 0);
+ /* kproc_fun has returned, and module is safe to unload. */
+}
+.Ed
.Sh ERRORS
The
.Fn kproc_resume
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 25, 9:13 AM (1 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30312990
Default Alt Text
D3390.id7966.diff (1 KB)
Attached To
Mode
D3390: improvements to kproc/kthread man pages
Attached
Detach File
Event Timeline
Log In to Comment