Re: Deadlock in My KEXT with NKE
Ok I tend to not explain what I am doing real well, sorry about that. I don't want to hold the funnel while it is sleeping, but keeping the state as it was before it slept. But the most important thing I am trying to do here is make it so that the Thread is sleeping while work is being done by the daemon so that it doesn't do a while loop without sleeping in the kernel, here is my while loop: work_to_do = 1; //int stuff = 0; while(conditional_val == 0) { (void) tsleep((caddr_t) & so->so_timeo, PSOCK, "Testing", 2 * hz); } //*top = NULL; conditional_val = 0; //return EACCES; work_to_do = 0; so as you see in the while loop it sleeps every time it goes through the loop so it doesn't spend lots of CPU trudging through the loop over and over. It does the while loop while the dameon is processing information. Also is there a way for the KEXT to detect if a daemon is running? On Feb 11, 2004, at 7:03 PM, Shawn Erickson wrote:
I don't think you can or should be able to hold a funnel when/if you
sleep your thread. Once your thread wakes I believe it gets the funnel
back before continuing if it held the funnel when it slept.
Given what you have listed so far I cannot make much sense of what you
are attempting to do... maybe some else can...?
-Shawn
On Feb 11, 2004, at 5:52 PM, Matt Jaffa wrote:
SO I was reading in the archives that if my NKE send function is
blocked(or in this case sleeping) it releases control of the funnel,
this is what could be causeing the Deadlock maybe.
And I was also reading that you have to lock it so that the state
isn't changed and won't cause this deadlock, it pointed me to
sys/lock.h
Using this how do I lock that so that it doesn't give up the funnel
while it is sleeping.
thanks,
Matt
On Feb 11, 2004, at 1:39 PM, Matt Jaffa wrote:
Hi all,
I have done alot of researching on this and can't find a way to do
this.
I have my KEXT which is a NKE, and I am specifically playing with
the send function so that
I can monitor and control all outgoing traffic from my computer.
I have succeeded in finishing my program, but after using it for a
little bit
it goes into Deadlock.
I look at my code and I can see why.
In my send function I have it surrounded by the the thread_tunnel
involving network_flock as to make sure only one send function is
being dealed with at a time, After which my send function signals a
global static variable work_to_do = 1, that informs the daemon
which is polling using sysctlbyname(...), that there is work to be
done, and then in the KEXT's NKE's send function it does a
while(conditional_val == 0) {
the functions that causes it to sleep;
}
then when the dameon is finished with the work, it signals by
sysctlbyname that conditional_val = 1 which causes the NKE's
send function to get out of the while loop.
This way is working pretty well, except after awhile of using it, it
gums up and creates deadlock and also the CFUserNotificationCreate
in my Daemon stops popping up windows asking for input on what to do
for a connection,
And finally the only thing i can do then is hold down the poser
button to reboot.
I know probably the while loop is very stupid and dangerous to use
in the KEXT, it brings up questions like, what if the Daemon failed,
then it would be in a inifinite loop forever.
So any suggestions of what to do now, of how to know if the Daemon
is running and also to block the send function until my dameon is
done with work and then to notify the NKE. Presently my daemon when
it first starts up it signals to the KEXT it is running and sets
that global static variable, but if the daemon were to die, the
KEXT wouldn't know.
Thanks for listening to my blabbing on.
Matt
P.S. I really did research this but I can't find anything on it,
yeah maybe I don't know how to search well, but please help.
I hope I explained this as best as possible.
_______________________________________________
darwin-kernel mailing list | darwin-kernel@lists.apple.com
Help/Unsubscribe/Archives:
Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-kernel mailing list | darwin-kernel@lists.apple.com
Help/Unsubscribe/Archives:
Do not post admin requests to the list. They will be ignored.
_______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Matt Jaffa