Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-28 Thread Alexander Ilin
Hello!

28.05.2016, 14:14, "Björn Lindqvist" :
> Hello,
>
> Here is some sample code to run:
>
> USING: alien io kernel threads.private windows.kernel32
> windows.types ;
> IN: examples.windows.threads
>
> : eternity ( -- ) eternity ;
>
> :  ( -- alien )
> DWORD { LPVOID } stdcall [ drop eternity 0 ] alien-callback ;
>
> : start-thread ( -- handle )
> f 0  f 0 f CreateThread ;
>
> : main ( -- )
> start-thread drop
> "I am here" print flush
> 20,000,000,000 (sleep) ;
>
> MAIN: main
>
> As you can see, it taxes the cpu 100% which proves that the thread is
> running. Then something triggers a gc and it crashes. It is not
> unexpected.

  I see now. I've modified the main word to contain "start-thread drop 
eternity", and it doesn't crash. I see two threads happily busy forever. This 
means that the code works. It was confusing for me before this experiment, 
because what I saw was an instant crash. I guess the reason must be that GC is 
called all the time by the UI (maybe it's specific to Windows implementation). 
And if you don't get back to the UI, no GC, no crash.

  At least that's a theory one can work with. Let's assume it's the GC's fault.

> You are kind of entering unexplored territory here. No one has ensured
> that factor works correctly when running kernel threads containing
> factor code. You aren't meant to do it.

  I remember in Slava's Google Talk there were some plans for native 
multithreading...
  https://www.youtube.com/watch?v=f_0QlhYlS8g

> However, you can start and run a thread written in C++ in the VM using
> start_thread() as long as you are careful not to mess with the
> factor_vm object in unapproved ways. You can see how it is done in
> start_sampling_profiler_timer() in vm/os-windows.cpp.

  Yes, I'll have to try that approach, although it would've been cool to stick 
to the higher level language.
  OTOH, maybe that kind of functionality does belong in the VM.

> I still don't understand how you can get that thread to trap the
> ctrl+break key combo. But if you can, then great!

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-28 Thread Alexander Ilin
Thank you, Björn, I'll give that a try.

In the meantime, has anyone tried debugging the VM under Visual Studio 2015? 
The build tool is command-line, and I see no VS solution file.

28.05.2016, 14:14, "Björn Lindqvist" :
> Hello,
>
> Here is some sample code to run:
>
> USING: alien io kernel threads.private windows.kernel32
> windows.types ;
> IN: examples.windows.threads
>
> : eternity ( -- ) eternity ;
>
> :  ( -- alien )
> DWORD { LPVOID } stdcall [ drop eternity 0 ] alien-callback ;
>
> : start-thread ( -- handle )
> f 0  f 0 f CreateThread ;
>
> : main ( -- )
> start-thread drop
> "I am here" print flush
> 20,000,000,000 (sleep) ;
>
> MAIN: main
>
> As you can see, it taxes the cpu 100% which proves that the thread is
> running. Then something triggers a gc and it crashes. It is not
> unexpected.
>
> You are kind of entering unexplored territory here. No one has ensured
> that factor works correctly when running kernel threads containing
> factor code. You aren't meant to do it.
>
> However, you can start and run a thread written in C++ in the VM using
> start_thread() as long as you are careful not to mess with the
> factor_vm object in unapproved ways. You can see how it is done in
> start_sampling_profiler_timer() in vm/os-windows.cpp.
>
> I still don't understand how you can get that thread to trap the
> ctrl+break key combo. But if you can, then great!
>
> 2016-05-27 22:16 GMT+02:00 Alexander Ilin :
>>  Hello!
>>
>>  27.05.2016, 20:00, "Björn Lindqvist" :
>>>  Try defining  like this:
>>>
>>>  :  ( -- alien ) DWORD { LPVOID } stdcall [ ] alien-callback ;
>>
>>    Tried this, see below.
>>
>>    I'm now at home, trying these things on Win 8.1 64-bit, on a freshly 
>> bootstrapped Factor. (For some reason the build.cmd produced a 32-bit 
>> executable, even though I'm on a 64-bit system.) The Windows Error Reporting 
>> tool (WerFault.exe) says that an exception is happening. Sometimes I get to 
>> see some kind of dumps in the console, sometimes not.
>>
>>    Here's my code:
>>
>>  USING: kernel windows.kernel32
>>  alien alien.data alien.syntax windows.types ;
>>  IN: my-thd
>>
>>  LIBRARY: kernel32
>>
>>  FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
>>  SIZE_T dwStackSize,
>>  LPVOID lpStartAddress,
>>  LPVOID lpParameter,
>>  DWORD dwCreationFlags,
>>  LPDWORD lpThreadId )
>>
>>  CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
>>
>>  :  ( -- alien )
>>    [ [ t ] [ ] while ] ThreadProc ;
>>
>>  :  ( -- alien )
>>    DWORD { LPVOID } stdcall [ ] alien-callback ;
>>
>>  :  ( -- alien )
>>    DWORD { LPVOID } stdcall [ [ t ] [ ] while ] alien-callback ;
>>
>>  : start-thd ( -- hnd )
>>  f 0  f 0 f CreateThread ;
>>
>>  : start-thd-2 ( -- hnd )
>>  f 0  f 0 f CreateThread ;
>>
>>  : start-thd-3 ( -- hnd )
>>  f 0  f 0 f CreateThread ;
>>
>>    Test runs and results:
>>    start-thd: the app sometimes dies with no output. WerFault sometimes 
>> reports Exception Code c409, which Googles to "Stack buffer overflow", 
>> and sometimes c005, which is "access violation". Sometimes I see a 
>> console dump, which starts with "fatal_error: Memory protection fault during 
>> gc: ".
>>
>>    start-thd-2: most of the time dies with no output, but once I saw the 
>> text "Error in print-error!" on the console.
>>
>>    start-thd-3: most of the time dies with no output, but once I saw a 
>> message box with "Memory protection fault at address 0x105" in it.
>>
>>    Can you help me? I need more code to try.

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-28 Thread Björn Lindqvist
Hello,

Here is some sample code to run:

USING: alien io kernel threads.private windows.kernel32
windows.types ;
IN: examples.windows.threads

: eternity ( -- ) eternity ;

:  ( -- alien )
DWORD { LPVOID } stdcall [ drop eternity 0 ] alien-callback ;

: start-thread ( -- handle )
f 0  f 0 f CreateThread ;

: main ( -- )
start-thread drop
"I am here" print flush
20,000,000,000 (sleep) ;

MAIN: main

As you can see, it taxes the cpu 100% which proves that the thread is
running. Then something triggers a gc and it crashes. It is not
unexpected.

You are kind of entering unexplored territory here. No one has ensured
that factor works correctly when running kernel threads containing
factor code. You aren't meant to do it.

However, you can start and run a thread written in C++ in the VM using
start_thread() as long as you are careful not to mess with the
factor_vm object in unapproved ways. You can see how it is done in
start_sampling_profiler_timer() in vm/os-windows.cpp.

I still don't understand how you can get that thread to trap the
ctrl+break key combo. But if you can, then great!


2016-05-27 22:16 GMT+02:00 Alexander Ilin :
> Hello!
>
> 27.05.2016, 20:00, "Björn Lindqvist" :
>> Try defining  like this:
>>
>> :  ( -- alien ) DWORD { LPVOID } stdcall [ ] alien-callback ;
>
>   Tried this, see below.
>
>   I'm now at home, trying these things on Win 8.1 64-bit, on a freshly 
> bootstrapped Factor. (For some reason the build.cmd produced a 32-bit 
> executable, even though I'm on a 64-bit system.) The Windows Error Reporting 
> tool (WerFault.exe) says that an exception is happening. Sometimes I get to 
> see some kind of dumps in the console, sometimes not.
>
>   Here's my code:
>
> USING: kernel windows.kernel32
> alien alien.data alien.syntax windows.types ;
> IN: my-thd
>
> LIBRARY: kernel32
>
> FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
> SIZE_T dwStackSize,
> LPVOID lpStartAddress,
> LPVOID lpParameter,
> DWORD dwCreationFlags,
> LPDWORD lpThreadId )
>
> CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
>
> :  ( -- alien )
>   [ [ t ] [ ] while ] ThreadProc ;
>
>
> :  ( -- alien )
>   DWORD { LPVOID } stdcall [ ] alien-callback ;
>
> :  ( -- alien )
>   DWORD { LPVOID } stdcall [ [ t ] [ ] while ] alien-callback ;
>
>
> : start-thd ( -- hnd )
> f 0  f 0 f CreateThread ;
>
> : start-thd-2 ( -- hnd )
> f 0  f 0 f CreateThread ;
>
> : start-thd-3 ( -- hnd )
> f 0  f 0 f CreateThread ;
>
>   Test runs and results:
>   start-thd: the app sometimes dies with no output. WerFault sometimes 
> reports Exception Code c409, which Googles to "Stack buffer overflow", 
> and sometimes c005, which is "access violation". Sometimes I see a 
> console dump, which starts with "fatal_error: Memory protection fault during 
> gc: ".
>
>   start-thd-2: most of the time dies with no output, but once I saw the text 
> "Error in print-error!" on the console.
>
>   start-thd-3: most of the time dies with no output, but once I saw a message 
> box with "Memory protection fault at address 0x105" in it.
>
>   Can you help me? I need more code to try.
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-28 Thread Alexander Ilin
Hello!

  Also, sometimes trying to run
USE: my-thd start-thd
  I get a message box saying "Memory protection fault at address 0x", 
and then I can inspect things at the Factor's console window. In these cases I 
see something like this on the Data Stack:
1057
{ 64199 16 8 f }

  The number in the first line randomly changes in the range about 1050..1115.
  The second to last number in the sequence (8 in the example above) is the 
same number that is the address of the memory protection fault in the message 
box.
  The first and last items of the sequence (64199 and f) are always the same.
  In place of 16 I saw similarly small even numbers: 10, 12, 16, 8.

28.05.2016, 13:26, "Alexander Ilin" :
> Hello!
>
>   A fun observation. Sometimes, when the Factor application is not 
> immediately terminated and an error dialog is shown on screen, I can inspect 
> it with the Process Explorer and see that my busy-loop thread is in there, 
> created and running.
>
> 27.05.2016, 23:16, "Alexander Ilin" :
>>  Hello!
>>
>>  27.05.2016, 20:00, "Björn Lindqvist" :
>>>   Try defining  like this:
>>>
>>>   :  ( -- alien ) DWORD { LPVOID } stdcall [ ] alien-callback ;
>>
>>    Tried this, see below.
>>
>>    I'm now at home, trying these things on Win 8.1 64-bit, on a freshly 
>> bootstrapped Factor. (For some reason the build.cmd produced a 32-bit 
>> executable, even though I'm on a 64-bit system.) The Windows Error Reporting 
>> tool (WerFault.exe) says that an exception is happening. Sometimes I get to 
>> see some kind of dumps in the console, sometimes not.
>>
>>    Here's my code:
>>
>>  USING: kernel windows.kernel32
>>  alien alien.data alien.syntax windows.types ;
>>  IN: my-thd
>>
>>  LIBRARY: kernel32
>>
>>  FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
>>  SIZE_T dwStackSize,
>>  LPVOID lpStartAddress,
>>  LPVOID lpParameter,
>>  DWORD dwCreationFlags,
>>  LPDWORD lpThreadId )
>>
>>  CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
>>
>>  :  ( -- alien )
>>    [ [ t ] [ ] while ] ThreadProc ;
>>
>>  :  ( -- alien )
>>    DWORD { LPVOID } stdcall [ ] alien-callback ;
>>
>>  :  ( -- alien )
>>    DWORD { LPVOID } stdcall [ [ t ] [ ] while ] alien-callback ;
>>
>>  : start-thd ( -- hnd )
>>  f 0  f 0 f CreateThread ;
>>
>>  : start-thd-2 ( -- hnd )
>>  f 0  f 0 f CreateThread ;
>>
>>  : start-thd-3 ( -- hnd )
>>  f 0  f 0 f CreateThread ;
>>
>>    Test runs and results:
>>    start-thd: the app sometimes dies with no output. WerFault sometimes 
>> reports Exception Code c409, which Googles to "Stack buffer overflow", 
>> and sometimes c005, which is "access violation". Sometimes I see a 
>> console dump, which starts with "fatal_error: Memory protection fault during 
>> gc: ".
>>
>>    start-thd-2: most of the time dies with no output, but once I saw the 
>> text "Error in print-error!" on the console.
>>
>>    start-thd-3: most of the time dies with no output, but once I saw a 
>> message box with "Memory protection fault at address 0x105" in it.
>>
>>    Can you help me? I need more code to try.
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-28 Thread Alexander Ilin
Hello, John! 28.05.2016, 00:10, "John Benediktsson" : IIRC, there are x86 (32-bit) and x64 (64-bit) versions of some of the VS Command Prompt shortcuts and they setup environment variables that will cause a 32-bit or 64-bit factor to be produced. Ah, good point. That might be it. ---=---Александр 

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread John Benediktsson
>
>   I'm now at home, trying these things on Win 8.1 64-bit, on a freshly
> bootstrapped Factor. (For some reason the build.cmd produced a 32-bit
> executable, even though I'm on a 64-bit system.) The Windows Error
> Reporting tool (WerFault.exe) says that an exception is happening.
> Sometimes I get to see some kind of dumps in the console, sometimes not.


IIRC, there are x86 (32-bit) and x64 (64-bit) versions of some of the VS
Command Prompt shortcuts and they setup environment variables that will
cause a 32-bit or 64-bit factor to be produced.
--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Björn Lindqvist
Try defining  like this:

:  ( -- alien ) DWORD { LPVOID } stdcall [ ] alien-callback ;

2016-05-27 18:03 GMT+02:00 Alexander Ilin :
> Hello, John!
>
> 27.05.2016, 18:55, "John Benediktsson" :
>> If you run it from the command prompt does it print an error message when it 
>> exits?
>
>   As I said, no message boxes, nothing on the console.
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Alexander Ilin
Hello, John!

27.05.2016, 18:55, "John Benediktsson" :
> If you run it from the command prompt does it print an error message when it 
> exits?

  As I said, no message boxes, nothing on the console.

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread John Benediktsson
If you run it from the command prompt does it print an error message when it 
exits?

> On May 27, 2016, at 8:51 AM, Alexander Ilin  wrote:
> 
> Hello!
> 
> 27.05.2016, 18:04, "John Benediktsson" :
>> Why do you have a busy loop on the callback? Why not just yield and return 
>> out of it?
> 
>  The busy loop is there to keep the new thread alive long enough so that I 
> can see it in the Process Explorer. The 100% CPU utilization will 1) tell me 
> that it's running, 2) help me tell it apart from the Listener's main thread 
> hosted in the same process.
> 
>> Maybe the callback is locking up the listener?
> 
>  The Listener doesn't lock up, it quits immediately. I have to start 
> Factor.exe/com again.
> 
> ---=---
> Александр
> 
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are 
> consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
> J-Flow, sFlow and other flows. Make informed decisions using capacity 
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Alexander Ilin
Hello!

27.05.2016, 18:04, "John Benediktsson" :
> Why do you have a busy loop on the callback? Why not just yield and return 
> out of it?

  The busy loop is there to keep the new thread alive long enough so that I can 
see it in the Process Explorer. The 100% CPU utilization will 1) tell me that 
it's running, 2) help me tell it apart from the Listener's main thread hosted 
in the same process.

> Maybe the callback is locking up the listener?

  The Listener doesn't lock up, it quits immediately. I have to start 
Factor.exe/com again.

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread John Benediktsson
Why do you have a busy loop on the callback?  Why not just yield and return out 
of it?  Maybe the callback is locking up the listener?

> On May 27, 2016, at 8:01 AM, Alexander Ilin  wrote:
> 
> Hello!
>  
> 27.05.2016, 17:35, "John Benediktsson" :
>> Since the 1234 is supposed to be a LPDWORD which I think should be a pointer 
>> wouldn't something like this work:
>>  
>> 1234 DWORD  
>>  
>> Note: I'm not a windows programmer, I just play one on TV.
>  
> Ha! : ))
>  
> That parameter is actually optional, according to the MSDN page on 
> CreateThread, so the following code should theoretically work:
>  
> USING: kernel windows.kernel32
> alien.data alien.syntax windows.types ;
> IN: my-thd
>  
> LIBRARY: kernel32
>  
> FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
> SIZE_T dwStackSize,
> LPVOID lpStartAddress,
> LPVOID lpParameter,
> DWORD dwCreationFlags,
> LPDWORD lpThreadId )
>  
> CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
>  
> :  ( -- alien )
>[ [ t ] [ ] while ] ThreadProc ;
>  
> : start-thd ( -- hnd )
>f 0  f 0 f CreateThread ;
>  
> It all compiles, but unfortunately, calling start-thd from the Listener 
> immediately terminates the Factor.com process. No message boxes, no console 
> output, nothing.
>  
> Any ideas?
>  
> ---=---
> Александр
>  
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are 
> consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
> J-Flow, sFlow and other flows. Make informed decisions using capacity 
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Alexander Ilin
Hello! 27.05.2016, 17:35, "John Benediktsson" :Since the 1234 is supposed to be a LPDWORD which I think should be a pointer wouldn't something like this work:     1234 DWORD   Note: I'm not a windows programmer, I just play one on TV.  Ha! : )) That parameter is actually optional, according to the MSDN page on CreateThread, so the following code should theoretically work: USING: kernel windows.kernel32    alien.data alien.syntax windows.types ;IN: my-thd LIBRARY: kernel32 FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,    SIZE_T dwStackSize,    LPVOID lpStartAddress,    LPVOID lpParameter,    DWORD dwCreationFlags,    LPDWORD lpThreadId ) CALLBACK: DWORD ThreadProc ( LPVOID lpParameter ) :  ( -- alien )   [ [ t ] [ ] while ] ThreadProc ; : start-thd ( -- hnd )   f 0  f 0 f CreateThread ; It all compiles, but unfortunately, calling start-thd from the Listener immediately terminates the Factor.com process. No message boxes, no console output, nothing. Any ideas? ---=---Александр --
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread John Benediktsson
Since the 1234 is supposed to be a LPDWORD which I think should be a
pointer wouldn't something like this work:

1234 DWORD 

Note: I'm not a windows programmer, I just play one on TV.

It's not automatically converted to a pointer.

On Fri, May 27, 2016 at 7:30 AM, Alexander Ilin  wrote:

> Thanks, John!
>
> This code compiles:
> :  ( -- alien )
>[ [ t ] [ ] while ] ThreadProc ;
>
> : start-thread ( -- hnd )
> f 1024  f 0 1234 CreateThread ;
>
> However, trying to run it results in an error which I don't understand:
> Generic word underlying>> does not define a method for the fixnum class.
> Dispatching on object: 1234
>
> Should I wrap 1234 with an  or something?
>
> 27.05.2016, 16:52, "John Benediktsson" :
>
> Note, your  needs to use the name of the Callback (in this
> case "ThreadProc") I think:
>
> : 
> [ ] ThreadProc ;
>
>
>
> On Fri, May 27, 2016 at 6:47 AM, Alexander Ilin  wrote:
>
>
>
> 27.05.2016, 12:56, "Björn Lindqvist" :
> > Yes. See
> https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks
> > for an example on how to pass callbacks to c functions.
>
> > So if CreateThread has signature:
> >
> > FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
> > SIZE_T dwStackSize,
> > LPVOID lpStartAddress,
> > LPVOID lpParameter,
> > DWORD dwCreationFlags,
> > LPDWORD lpThreadId )
> >
> > You need to declare a callback:
> >
> > CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
> >
> > Then a callback maker:
> >
> > :  ( -- alien )
> > [ ] comparer ; <-replace [ ] with your code
> >
> > Then call it:
> >
> > f 1024  f 0 1234 CreateThread
>
>   Thank you very much, Björn, that's exactly the kind of help I need right
> now.
>   Unfortunately, pasting your code in the Listener hangs it for some
> reason.
>
>   I have changed the  so that it would sit just there in the
> new thread:
>
> :  ( -- alien )
> [ t ] [ ] while 0 ; ! 0 is the return value, otherwise stack checker
> complains.
>
>   In the Process Monitor I see 100% CPU utilization in the main Factor.exe
> thread, and I see no additional thread created.
>   What might be the problem?
>
> Factor 0.98 x86.32 (1769, heads/master-6b77c4f3da, Tue May 10 15:22:01
> 2016)
> [Microsoft Visual C++ 190023506] on windows XP Pro SP3
>
> ---=---
>  Александр
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> ,
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ,
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> ---=---
> Александр
>
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. 

Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Alexander Ilin
Thanks, John! This code compiles::  ( -- alien )   [ [ t ] [ ] while ] ThreadProc ; : start-thread ( -- hnd )f 1024  f 0 1234 CreateThread ; However, trying to run it results in an error which I don't understand:Generic word underlying>> does not define a method for the fixnum class.Dispatching on object: 1234 Should I wrap 1234 with an  or something? 27.05.2016, 16:52, "John Benediktsson" :Note, your  needs to use the name of the Callback (in this case "ThreadProc") I think: :     [ ] ThreadProc ;   On Fri, May 27, 2016 at 6:47 AM, Alexander Ilin  wrote: 27.05.2016, 12:56, "Björn Lindqvist" :> Yes. See https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks> for an example on how to pass callbacks to c functions.> So if CreateThread has signature:>> FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,> SIZE_T dwStackSize,> LPVOID lpStartAddress,> LPVOID lpParameter,> DWORD dwCreationFlags,> LPDWORD lpThreadId )>> You need to declare a callback:>> CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )>> Then a callback maker:>> :  ( -- alien )> [ ] comparer ; <-replace [ ] with your code>> Then call it:>> f 1024  f 0 1234 CreateThread  Thank you very much, Björn, that's exactly the kind of help I need right now.  Unfortunately, pasting your code in the Listener hangs it for some reason.  I have changed the  so that it would sit just there in the new thread::  ( -- alien )    [ t ] [ ] while 0 ; ! 0 is the return value, otherwise stack checker complains.  In the Process Monitor I see 100% CPU utilization in the main Factor.exe thread, and I see no additional thread created.  What might be the problem?Factor 0.98 x86.32 (1769, heads/master-6b77c4f3da, Tue May 10 15:22:01 2016)[Microsoft Visual C++ 190023506] on windows XP Pro SP3---=--- Александр--What NetFlow Analyzer can do for you? Monitors network bandwidth and trafficpatterns at an interface-level. Reveals which users, apps, and protocols areconsuming the most bandwidth. Provides multi-vendor support for NetFlow,J-Flow, sFlow and other flows. Make informed decisions using capacityplanning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___Factor-talk mailing listFactor-talk@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/factor-talk,--What NetFlow Analyzer can do for you? Monitors network bandwidth and trafficpatterns at an interface-level. Reveals which users, apps, and protocols areconsuming the most bandwidth. Provides multi-vendor support for NetFlow,J-Flow, sFlow and other flows. Make informed decisions using capacityplanning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e,___Factor-talk mailing listFactor-talk@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/factor-talk  ---=---Александр --
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread John Benediktsson
Note, your  needs to use the name of the Callback (in this case
"ThreadProc") I think:

: 
[ ] ThreadProc ;



On Fri, May 27, 2016 at 6:47 AM, Alexander Ilin  wrote:

>
>
> 27.05.2016, 12:56, "Björn Lindqvist" :
> > Yes. See
> https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks
> > for an example on how to pass callbacks to c functions.
>
> > So if CreateThread has signature:
> >
> > FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
> > SIZE_T dwStackSize,
> > LPVOID lpStartAddress,
> > LPVOID lpParameter,
> > DWORD dwCreationFlags,
> > LPDWORD lpThreadId )
> >
> > You need to declare a callback:
> >
> > CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
> >
> > Then a callback maker:
> >
> > :  ( -- alien )
> > [ ] comparer ; <-replace [ ] with your code
> >
> > Then call it:
> >
> > f 1024  f 0 1234 CreateThread
>
>   Thank you very much, Björn, that's exactly the kind of help I need right
> now.
>   Unfortunately, pasting your code in the Listener hangs it for some
> reason.
>
>   I have changed the  so that it would sit just there in the
> new thread:
>
> :  ( -- alien )
> [ t ] [ ] while 0 ; ! 0 is the return value, otherwise stack checker
> complains.
>
>   In the Process Monitor I see 100% CPU utilization in the main Factor.exe
> thread, and I see no additional thread created.
>   What might be the problem?
>
> Factor 0.98 x86.32 (1769, heads/master-6b77c4f3da, Tue May 10 15:22:01
> 2016)
> [Microsoft Visual C++ 190023506] on windows XP Pro SP3
>
> ---=---
>  Александр
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Alexander Ilin


27.05.2016, 12:56, "Björn Lindqvist" :
> Yes. See 
> https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks
> for an example on how to pass callbacks to c functions.

> So if CreateThread has signature:
>
> FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
> SIZE_T dwStackSize,
> LPVOID lpStartAddress,
> LPVOID lpParameter,
> DWORD dwCreationFlags,
> LPDWORD lpThreadId )
>
> You need to declare a callback:
>
> CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
>
> Then a callback maker:
>
> :  ( -- alien )
> [ ] comparer ; <-replace [ ] with your code
>
> Then call it:
>
> f 1024  f 0 1234 CreateThread

  Thank you very much, Björn, that's exactly the kind of help I need right now.
  Unfortunately, pasting your code in the Listener hangs it for some reason.

  I have changed the  so that it would sit just there in the new 
thread:

:  ( -- alien )
[ t ] [ ] while 0 ; ! 0 is the return value, otherwise stack checker 
complains.

  In the Process Monitor I see 100% CPU utilization in the main Factor.exe 
thread, and I see no additional thread created.
  What might be the problem?

Factor 0.98 x86.32 (1769, heads/master-6b77c4f3da, Tue May 10 15:22:01 2016)
[Microsoft Visual C++ 190023506] on windows XP Pro SP3

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Björn Lindqvist
Hi,

>   OK, good. When I call CreateThread, one of the parameters I need to pass it 
> is a function pointer to the code which will run in the new thread. My 
> question is: can I pass a Factor quotation or a word as the function pointer? 
> Or is there some wrapper to make it possible, like with-new-vm or something?
>

Yes. See 
https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks
for an example on how to pass callbacks to c functions. So if
CreateThread has signature:

FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize,
LPVOID lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId )

You need to declare a callback:

CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )

Then a callback maker:

:  ( -- alien )
[ ] comparer ;  <-replace [ ] with your code

Then call it:

f 1024  f 0 1234 CreateThread


-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Alexander Ilin
Hello!

27.05.2016, 02:48, "Björn Lindqvist" :
> You could certainly wrap the CreateThread function and call it from
> factor. See the windows.kernel32 vocab for how wrapping Windows system
> functions are done.

  OK, good. When I call CreateThread, one of the parameters I need to pass it 
is a function pointer to the code which will run in the new thread. My question 
is: can I pass a Factor quotation or a word as the function pointer? Or is 
there some wrapper to make it possible, like with-new-vm or something?

> On the VM:s level, threads are started with the start_thread() function which 
> is defined in vm/os-windows.cpp.

  Good, thank you.

> Oh, and didn't we discuss this issue last year?

  We sure did, but you guys left me hanging. Nobody reacted to my suggestion 
and I did not get the help I needed, so I'm making a second attempt at fixing 
it now. This time I feel more confident I can do it with little supervision.

---=---
 Александр

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-26 Thread Björn Lindqvist
Hello,

You could certainly wrap the CreateThread function and call it from
factor. See the windows.kernel32 vocab for how wrapping Windows system
functions are done. On the VM:s level, threads are started with the
start_thread() function which is defined in vm/os-windows.cpp. Oh, and
didn't we discuss this issue last year?
https://sourceforge.net/p/factor/mailman/message/34507872/



2016-05-26 21:33 GMT+02:00 Alexander Ilin :
> Hello again!
>
>   To fix https://github.com/factor/factor/issues/1573 I need to know one 
> thing: can I start a native thread (WinAPI CreateThread) within the 
> Factor.exe process with Factor code running in it? If so, how do I do it?
>
>   If not, I'll have to implement it in VM's C++ code.
>
> ---=---
>  Александр
>
> --
> Mobile security can be enabling, not merely restricting. Employees who
> bring their own devices (BYOD) to work are irked by the imposition of MDM
> restrictions. Mobile Device Manager Plus allows you to control only the
> apps on BYO-devices by containerizing them, leaving personal data untouched!
> https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Issue #1573: interrupt a tight loop

2016-05-26 Thread Alexander Ilin
Hello again!

  To fix https://github.com/factor/factor/issues/1573 I need to know one thing: 
can I start a native thread (WinAPI CreateThread) within the Factor.exe process 
with Factor code running in it? If so, how do I do it?

  If not, I'll have to implement it in VM's C++ code.

---=---
 Александр

--
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk