DOS-handler completion with AmigaOS4.1Final

A forum for general AmigaOS 4.x support questions that are not platform-specific
User avatar
gdridi
Posts: 64
Joined: Sat Aug 11, 2012 10:17 am

DOS-handler completion with AmigaOS4.1Final

Post by gdridi »

Hello,

Is there a change with DOS-handler (task) termination with AmigaOS4.1Final ?
Because I always see the "DOS-handler 0.5 task" not finished when I quit (using " tasklist " command).
Before Final Edition my DOS-handler tasks quit nicely , but now they stay waiting... some clues ?

Thank you,
Regards,
DGILLES
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: DOS-handler completion with AmigaOS4.1Final

Post by nbache »

DOS-handler?

Not sure what that is.

These are the handlers running on my FE Update 2 system shortly after booting:

Code: Select all

> tasklist | grep handler
0x504544E0	process	5	waiting	65528	476	CON/con-handler 53.82 
0x51FD60D0	process	5	waiting	65528	732	PIPE/queue-handler 53.4 
0x5263DE30	process	5	waiting	65528	732	PIPE/queue-handler 53.4 
0x521EC3A0	process	3	waiting	65528	316	TEXTCLIP/textclip-handler 53.4 
0x521EC220	process	5	waiting	503800	16476	URL/launch-handler 53.39 
0x5045E1F0	process	5	waiting	65528	476	CON/con-handler 53.82 
0x50454C60	process	5	waiting	65528	476	CON/con-handler 53.82 
0x50454AE0	process	5	waiting	65528	476	CON/con-handler 53.82 
0x50733610	process	5	waiting	65528	476	CON/con-handler 53.82 
0x50733310	process	5	waiting	65528	476	CON/con-handler 53.82 
0x507F2D80	process	5	waiting	65528	476	CON/con-handler 53.82 
0x507F2180	process	5	waiting	65528	476	CON/con-handler 53.82 
0x51FD6B50	process	5	waiting	65528	476	CON/con-handler 53.82 
0x521EC520	process	5	waiting	65528	316	APPDIR/appdir-handler 54.17 
0x52C0D1A0	process	10	waiting	16376	700	RAM/ram-handler 54.24 
0x52C0D320	process	5	waiting	32760	268	ENV/env-handler 54.18 
0x52EE1A90	process	5	waiting	32760	476	CON/con-handler 53.82 
0x52EE1910	process	5	waiting	32760	476	RAW/con-handler 53.82 
0x52EE1790	process	5	waiting	32760	476	CON/con-handler 53.82 
0x6FB8E4E0	process	19	waiting	16376	220	SFS DosList handler
0x6FD747D0	process	5	waiting	16376	252	dos_lock_handler
Anyway, what do you mean when you say "quit"? You don't expect to be able to use the WB menu to quit, do you?

This is not Windows - just turn off your machine :-) (after waiting a moment after any disk accesses).

Best regards,

Niels
User avatar
gdridi
Posts: 64
Joined: Sat Aug 11, 2012 10:17 am

Re: DOS-handler completion with AmigaOS4.1Final

Post by gdridi »

Hello,

Sorry it was not clear.

I wrote a DOS-handler named ACON,
So I see in the tasklist : ACON/DOS-handler 0.5 with AmigaOSFinal EditionU0.
But when my program, using this handler (which open it, close it), quit , I see the occurrence of tasks growing, so the ACON/DOS-handler 0.5 (task)process are always waiting.

I hope, it is better explained.

Thank you for your time.
Regards,
DGILLES
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: DOS-handler completion with AmigaOS4.1Final

Post by nbache »

Ah, I see.

That's not something I know much about - intuitively I'd think it would be your own code in the handler which should decide whether to shut down or stay waiting when no more callers are using it, but I don't know for sure.

Hopefully Colin sees this and has more solid info.

Best regards,

Niels
User avatar
gdridi
Posts: 64
Joined: Sat Aug 11, 2012 10:17 am

Re: DOS-handler completion with AmigaOS4.1Final

Post by gdridi »

Thank you Niels,

Sometimes when I quit the program that have open my ACON handler, it crashes and There’s a pop-up saying :
"
Function : Wait_Until_Child_Ends
"
I suppose because I used NP_Child True when creating a process which shares data with the my ACON handler code.

But perhaps this is another issue with no matters with ACON/DOS-handler 0.5 task/process which won’t end up with my code with FinalEdition.
Because, ACON process tends to end before FinalEdition (4.1 update 0/1).

Hope Colin’s explain me what to do to solve.

Best regards,
DGILLES
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: DOS-handler completion with AmigaOS4.1Final

Post by colinw »

Without seeing your source code to look what you are doing, it's difficult to say exactly
what is causing your problem, however you did mentioned above;
I suppose because I used NP_Child True when creating a process which shares data with the my ACON handler code.
There's at least two problems with that sentence.

When creating a process with NP_Child,TRUE the child ABSOLUTELY MUST exit before the parent can do so,
there needs to be robust exit arbitration put in place by the parent, so this always happens,
See IDOS->WaitForChildExit() and also IDOS->CheckForChildExit(), also the autodoc for IDOS->CreateNewProc()
has several code examples on how to do this on earlier DOS releases.

Secondly, you must not share data with any DOS handler process that does not come in via a dospacket
(or vector port function for new style filesystems)

All DOS handlers must be re-entrant, the same loaded code can be run by multiple processes concurrently,
so the handler process must open any resources itself and delete them on exit itself,
and the handler process is never flagged as an NP_Child when started by DOS.
You can only have READABLE global data that the handler process accesses, and WRITABLE data that is going
to be accessible between processes absolutely must be protected by a semaphore or mutex.

I am not sure why you are creating a process, but DOS takes care of starting up the handlers for you.
This happens automatically when something accesses the device name in the doslist.
Specifically when something calls the IDOS->GetDeviceProc[Flags] function.

So, please check the packet autodocs for ACTION_STARTUP, it will show the handler startup proceedure.

Other than the above, you can run the FSVPTool in SDK:c and look at the start.c function for example
code of starting up a new style filesystem handler, just ignore the vector-port stuff if you are doing
a dospacket based handler.

I hope this helps.
User avatar
gdridi
Posts: 64
Joined: Sat Aug 11, 2012 10:17 am

Re: DOS-handler completion with AmigaOS4.1Final

Post by gdridi »

Hello @Niels @Colinw @Amigans

For the termination problem I used a Forbid() call just before the return 0; of my "other task".
And now the cumulative trouble of tasks DOS-handler not finishing is removed. Great !

For the child (i.e the "other task") to terminate before the parent ; that is not a good idea.
Because code must be multi core proof ! Other process can enter so I remove NP_Child, TRUE, and replace by NP_FreeSeglist, FALSE, finger crossed no more crash.

Now the forwarding question : how to REMOVE the DOS VOLUME AND ITS TASK ?
I use :
assign ACON: remove
Or
C:dismount ACON: force

But they remove the volume ACON: from the volume list visible by assign command alone but not the DOS-handler task.
Any idea ?

Afterwards I can use a : break process name ctrl_F, because my ACON: can terminate on Ctrl_F signal but this command do not found the process name… given : "ACON/DOS-handler 0.5"
Any idea ?

I will open another topic for : "display and key strokes" not stop on key up ; when using IIR VANILLA KEY or something like this with input.device or console.device
Topic for @tonyw

Best weekend to all
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: DOS-handler completion with AmigaOS4.1Final

Post by colinw »

gdridi wrote: Fri Jun 04, 2021 11:14 pm Hello @Niels @Colinw @Amigans

For the termination problem I used a Forbid() call just before the return 0; of my "other task".
And now the cumulative trouble of tasks DOS-handler not finishing is removed. Great !
IExec->Forbid() is -NOT- a valid process exit arbitration mechanism.
IExec->Wait() breaks IExec->Forbid() and during a process cleanup, any internal DOS calls to
IDOS->Unlock() or IDOS->Close() for the default locks or streams can result in either a Wait()
from a DosPacket transaction or a Signal Semaphore(), so don't do it. !!!
For the child (i.e the "other task") to terminate before the parent ; that is not a good idea.
Because code must be multi core proof ! Other process can enter so I remove NP_Child, TRUE, and replace by NP_FreeSeglist, FALSE, finger crossed no more crash.
There's no "fingers crossed" required if you do it properly.
Your plan to just leak the loaded segments memory away each time it starts and leave the child
process whizzing around in orphaned code forever, is wrong on so many levels and a dreadfull strategy.
Now the forwarding question : how to REMOVE the DOS VOLUME AND ITS TASK ?
I use :
assign ACON: remove
Or
C:dismount ACON: force

But they remove the volume ACON: from the volume list visible by assign command alone but not the DOS-handler task.
Any idea ?
Several actually;
1) ACON: is not an assignment, c:Assign is not going to help you.

2) Don't use the FORCE option for Dismount as an operational strategy, it leaks memory and is dangerous and
likely to crash the machine, please read the supplied documentation.

3) Write the handler properly so it exits automatically when the last lock/stream is released,
if that's how you want it to behave, or, have it start a new handler instance each time like CON:
(by not initialising dn_Port on startup, and exit upon Close() each time.)

I think you need to do some more research, a DOS handler is a bit ambitious.
User avatar
gdridi
Posts: 64
Joined: Sat Aug 11, 2012 10:17 am

Re: DOS-handler completion with AmigaOS4.1Final

Post by gdridi »

colinw wrote: Fri Jun 04, 2021 1:06 am Without seeing your source code to look what you are doing, it's difficult to say exactly
what is causing your problem, however you did mentioned above;
I suppose because I used NP_Child True when creating a process which shares data with the my ACON handler code.
There's at least two problems with that sentence.

When creating a process with NP_Child,TRUE the child ABSOLUTELY MUST exit before the parent can do so,
there needs to be robust exit arbitration put in place by the parent, so this always happens,
See IDOS->WaitForChildExit() and also IDOS->CheckForChildExit(), also the autodoc for IDOS->CreateNewProc()
has several code examples on how to do this on earlier DOS releases.

Secondly, you must not share data with any DOS handler process that does not come in via a dospacket
(or vector port function for new style filesystems)

All DOS handlers must be re-entrant, the same loaded code can be run by multiple processes concurrently,
so the handler process must open any resources itself and delete them on exit itself,
and the handler process is never flagged as an NP_Child when started by DOS.
You can only have READABLE global data that the handler process accesses, and WRITABLE data that is going
to be accessible between processes absolutely must be protected by a semaphore or mutex.

I am not sure why you are creating a process, but DOS takes care of starting up the handlers for you.
This happens automatically when something accesses the device name in the doslist.
Specifically when something calls the IDOS->GetDeviceProc[Flags] function.

So, please check the packet autodocs for ACTION_STARTUP, it will show the handler startup proceedure.

Other than the above, you can run the FSVPTool in SDK:c and look at the start.c function for example
code of starting up a new style filesystem handler, just ignore the vector-port stuff if you are doing
a dospacket based handler.

I hope this helps.
Which SDK version number to find start.c ?

Thereeafter, what the meaning of DosNode->dn_Task ?

/*
* Causes a new process to be created on next reference
*/

// DosNode->dn_Task = &DosProc->pr_MsgPort; ? WB error!
DosNode->dn_Task = FALSE;
//DosNode->dn_Task = 0L; // Pareil

I use the cat program, like cat <ACON: >ACON: creating only two (2) more ACON process-handler.

But the standard AmigaDOS: copy ACON: to ACON: creating me a lot more six (6) handlers ?
In addition to the two above.

Would you like to explain ? It is to AmigaDOS to close these extra handler copies?

For cat, we read angle brackets missing *>ACON: so this is clear, only input and output streams.
For copy, we suppose three input, output, output_error but two times (3 * 2 = 6).
Moreover the "classic" mines referenced ACON: ACON: two times ?

The best,
DGILLES
Last edited by gdridi on Sun Sep 12, 2021 10:46 pm, edited 1 time in total.
User avatar
polluks
Posts: 55
Joined: Tue May 19, 2015 6:30 pm
Location: Germany
Contact:

Re: DOS-handler completion with AmigaOS4.1Final

Post by polluks »

For DOS basics I still recommend the Guru Book http://babel.de/amiga.html#doc
Post Reply