help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] Ideas on finishing the Win32 port of GNU Smalltalk


From: Bonzini
Subject: [Help-smalltalk] Ideas on finishing the Win32 port of GNU Smalltalk
Date: Tue, 4 Mar 2003 20:32:55 +0100

Right now (not in 2.0k) the only missing part is I/O.  Unluckily, this is
going to be the hardest part because Win32 is rather different than Unix
(virtual memory was another area, but in that case Win32 was actually
cleaner in practice gst already used to emulate it under Unix!).

Here are the semantics of I/O under Unix. (I'll use "read" but it is the
same for writing and exceptional conditions).

1) you put the file descriptor in non-blocking mode.
2) you poll the file descriptor.  If you can read, do it (this is
_gst_sync_file_polling).
3) if you cannot, you put the descriptor in non-blocking mode and call
_gst_async_file_polling
4) kernel sends you a SIGIO when I/O can be done on an arbitrary file
descriptor
5) Go to 2.

Now, Win32 has "completion routines" and "completion events": it is more or
less the opposite, as its async I/O works by having the OS queue the request
rather than the application!  Async I/O works like this in Win32:

1) you use ReadFileEx and WriteFileEx to queue a request

The idea is to move the I/O routines (read and write) to sysdep.c: for Unix
they won't do anything special -- they'll just be wrappers -- while for
Win32 they will:

1) use _lseek to request the current position (this is needed for step 2).
If it fails just use 0.
2) save somewhere that a read/write is pending
3) queue a request with ReadFileEx and WriteFileEx.  Use _get_osfhandle to
retrieve the Win32 handle from the file descriptor.

For the other routines:
_gst_sync_polling -> Instead of using poll(2) check the flags that are set
by the wrappers.
_gst_set_file_interrupt -> Set another flag somewhere that SIGIO is desired

The completion routine will check the flags that are set by
_gst_set_file_interrupt and and raise a SIGIO if they are used.  The same
scheme can be done with WSARecv and WSASend as well.  So we'll have

_gst_read (new function)
_gst_write (new name of _gst_full_write)
_gst_recv (new function)
_gst_send (new name of _gst_full_send)

Anyway this is stuff for after 2.1 which will have a basic Win32 port
without fully working I/O.

|_  _  _ __
|_)(_)| ),'
------- '---





reply via email to

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