chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] udp egg on win32


From: Daishi Kato
Subject: Re: [Chicken-users] udp egg on win32
Date: Mon, 06 Feb 2006 13:13:38 +0900
User-agent: Wanderlust/2.15.1 (Almost Unreal) Emacs/21.4 Mule/5.0 (SAKAKI)

Gosh! A small sample program let me know
that it's not a udp problem at all,
but is my nbstdin egg problem.
It is because select() cannot be used for fd=0 on win32.
Sorry about that. The udp egg is innocent.
Your comments helped me a lot anyway.

As for tcp.scm, fcntl() is just disabled on win32.
So, using ioctlsocket() should be the correct way.
I guess that the socket is always non-blocking on win32,
given that tcp is working in any case.

Daishi

At Sun, 5 Feb 2006 17:05:10 +0100,
Hans Bulfone wrote:
> 
> hi,
> 
> On Sun, Feb 05, 2006 at 01:15:15PM +0900, Daishi Kato wrote:
> > Hi Hans,
> > 
> > > imho, they should not be commented out, because they are
> > > needed to tell the scheduler that the thread is waiting
> > > for some socket to be ready for reading or writing.
> > > 
> > > the scheduler then only invokes the thread when the
> > > socket is ready.
> > 
> > So, is it like a select() call?
> 
> yes, the scheduler uses select() internally and unblocks
> the thread when the fd is ready.  this is done in
> ##sys#unblock-threads-for-i/o, which is called in
> ##sys#schedule.  ##sys#thread-block-for-i/o! doesn't
> call select() itself, it only registers the fd and
> sets the thread's state to blocked.
> 
> > > without the ##sys#thread-block-for-i/o call, the scheduler
> > > invokes the thread repeatedly, the thread calls recv(),
> > > gets EWOULDBLOCK and (yield)s again.  this wastes a lot of
> > > cpu time, especially when all threads are waiting for i/o.
> > 
> > Ah, you are right. This is why it worked on win32.
> > I guess ##sys#thread-block-for-i/o does not work correctly
> > on win32, and without it, the thread is invoked repeatedly,
> > letting the program work WITH lots of cpu time...
> > 
> > Would there be a piece of code to see if
> > ##sys#thread-block-for-i/o is really working?
> 
> i think it would be useful to test a simple program that does
> (udp-recvfrom) in one thread and maybe prints a message on
> stdout every second in the main thread.
> 
> when you run this program with strace (which afaik is also
> available for windows), you should see if select() is called
> correctly and what it returns and if recv() behaves correctly
> and does not block.
> 
> another option would be to recompile chicken with the dbg
> macro in scheduler.scm commented in.
> 
> btw, i noticed, that in tcp.scm, fcntl() is used to set the
> O_NONBLOCK flag on both unix and windows, while in udp.scm
> ioctlsocket() is used on windows.
> 
> does tcp.scm work on windows? maybe udp.scm should also use
> fcntl() on windows?
> 
> regards,
> hans.
> 
> 
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users




reply via email to

[Prev in Thread] Current Thread [Next in Thread]