tech-kern archive

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

Re: workqueue semantics [was Re: How to identify specific wait-state for a "DE" process?]



On Tue, 5 Jan 2016, Thor Lancelot Simon wrote:

On Wed, Jan 06, 2016 at 11:38:00AM +0800, Paul Goyette wrote:
On Wed, 6 Jan 2016, Taylor R Campbell wrote:

 Date: Tue, 5 Jan 2016 21:48:42 -0500
 From: Thor Lancelot Simon <tls%panix.com@localhost>

 You can probably use workqueues for this.  Looking at the manual page
 again for the first time in years, I think it's a little misleading --
 what I believe is meant by "A work must not be enqueued again until the
 callback is called..." is really "a work item must not be re-enqueued
 before it has been processed by the *func callback", not the alternate,
 crazy reading that would imply workqueues can only have one enqueued
 item at a time.

Your reading of the man page is correct: it is the struct work, not
the struct workqueue *, that may not be reused until the callback is
run.

(I'm not sure how this would help for pgoyette's application, though.)

I don't know how it would help, either.  The best I can think of is to have
a periodic task run which checks to see if the file descriptor is being
closed;  if yes, then the code could release the reference and wake up the
condvar waiter.  But is this really a good thing to do?  And what would be
an appropriate interval?

Why do you need a periodic task?  When you enqueue the work to release the
reference, the workqueue framework will run the callback function -- in a
different thread.  Then it can wake you up.  Isn't that what you wanted?

The problem is, what triggers "enqueue to the work queue"? It needs to happen only _after_ entry to sys_exit(), but _before_ the exit code gets around to calling fd_free() which sequentially calls fd_close(fd) ...

I don't want to release the reference while things are running, only when they're done.

Something like an atexit(3) for the kernel!   :)



+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+


Home | Main Index | Thread Index | Old Index