26 January 2022, 22:13 | #1 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Loosing signals from STRING_KIND on 68000 machine
So I decided to test my program on a real A500 and I noticed some signals from the STRING_KIND gadget hook are being lost.
I have simplified the code so that I can focus on the issue. The hook code is as follows; Code:
ULONG press (struct Hook *hook, struct SGWork *obj, ULONG *msg) { c = obj->Code; // c is global variable. Signal(task, signal); return 0; } Code:
int s = Wait(1L << myWindow->UserPort->mp_SigBit | signal); ... else if(s & singal) { char t = c; FreeSignal(signal); { char *input = ((struct StringInfo *)(name->SpecialInfo))->Buffer; printf("%c-%d\n", t, strlen(input));} } ... However on a 68000 or 68010 I notice some signals are missing (depending on how fast I type). Example when I type slowly the text "Amiga" I get the following: Code:
A - 1 m - 2 i - 3 g - 4 a - 5 Code:
m - 2 a - 5 |
26 January 2022, 23:14 | #2 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,219
|
signal or singal?
maybe race condition? is it normal to FreeSignal before accessing the buffer? (just an idea). Freeing the signal after that may avoid the race condition ... or not Last edited by jotd; 26 January 2022 at 23:16. Reason: t |
26 January 2022, 23:22 | #3 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,002
|
I see two possible reasons.
Firstly you have a call to FreeSignal in the code which for me seems completely out of sync. At least there is no corresponding AllocSignal. In any case you make a big mistake in function calls. AllocSignal and FreeSignal act on signal numbers, that is a BYTE value between 0 and 31 or -1 for failure. Wait() and Signal() on the other hand act on signal masks, i.e. a 32bit ULONG with the n'th bit set. So for example if AllocSignal returns bit #8, the corresponding signal mask is 0x100 or 256. Now if your Wait() and Signal() logic works, then your above code gives the signal mask to FreeSignal instead of the signal number. This is wrong. Because a signal with number 256 does not exist, the FreeSignal call does nothing. If you do AllocSignal/FreeSignal this way in a loop, you quickly run out of signals because each call to FreeSignal fails. The other possible reason is speed. A signal is not a message. A signal is just a bit in the task structure. Once a signal is set, it remains set until somebody clears it. The Wait() call does clear the signal. But if you type so fast that your main routine cannot catch each signal with Wait() then every other signal is lost. If your app depends on the fact that each "signal" is received, then an AmigaOS signal is not the right method to use. In this case you have to send a message to a message port. The port will queue all messages until they are processed. BTW, a port uses signals, too. The port's signal indicates that new messages have arrived. It does not say how many. It's just one bit, it can be on or off. It cannot hold more information. One remark: if the only intention behind all this effort is debugging, then you should rather use kprintf in your edit hook. Then you don't need to care about signal or message forwarding. Your debug output will appear on the serial port or, if you run Sashimi first, in a separate window. Last edited by thomas; 26 January 2022 at 23:27. |
27 January 2022, 01:20 | #4 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Sorry that was a typo, did not copy paste that line. Can confirm it is signal.
I clearly misunderstood what FreeSignal is meant to do. I thought it was the equivalent of GT_ReplyIMsg, i.e. - that when I received a signal I needed to release it. I have now removed this and instead moved it to the section where I clean resources when closing the application. I have also corrected the mistake and no longer FreeSignal(signal) but FreeSignal(signalId) where signalId store the result returned from AllocSignal(). Thank you for pointing this out. Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Intuition - Menu Command Keys and STRING_KIND gadgets | Sim085 | Coders. C/C++ | 7 | 26 January 2022 11:10 |
Raise event from STRING_KIND gadget without loosing focus? | Sim085 | Coders. C/C++ | 3 | 16 July 2020 20:25 |
Use two or more colours in STRING_KIND gadget at the same time. | Sim085 | Coders. C/C++ | 1 | 02 July 2020 06:21 |
Cd32 Rx Tx Signals | amigoun | support.Hardware | 13 | 21 December 2017 14:46 |
Loosing my mind | webmany | New to Emulation or Amiga scene | 3 | 11 September 2005 09:27 |
|
|