Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!wuarchive!uunet!fernwood!portal!cup.portal.com!phorgan From: phorgan@cup.portal.com (Patrick John Horgan) Newsgroups: comp.sys.amiga.programmer Subject: Re: General questions regarding Tasks Message-ID: <42787@cup.portal.com> Date: Wed, 29 May 91 23:14:32 PDT Organization: The Portal System (TM) References: <1991May24.160440.374@m.cs.uiuc.edu> <1991May24.120133.31035@kuhub.cc.ukans.edu> Mark Gooderum said: >A task function should be an endless loop with some kind of check for >an exit condition. Since RemTask(called by DeleteTask) can be picky >about conditions, it should call Wait(0L) (wait forever) to put itself >in a safe state to be deleted by the parent. Alternately a task can >RemTask(0L) itself, but this doesn't clean up the allocations for the >stack and TCB. CreateTask and DeleteTask are not system calls, but rather library routines provided by your friendly C compiler folks. I rewrote mine to allocate the memory for the stack, the TCB and the name of the task as part of the tc_MemEntry list so that when a RemTask is done the memory is freed by the operating system. I originally started mucking around with it because Manx's routine didn't allocate memory for the name pointer passed to it, it just stored the string address passed to it into the Nodes name. This non-reentrency broke my code which spawned many tasks (alright it only made all the tasks have the same name, but debugging was weird!). I sent the new code to Manx, but haven't checked since 5.0 came out to see if they included it. I also sent them Create/Delete Port code to replace theirs with the same problem. I haven't checked to see if they used it either. It's easy (just a few minutes after using the CreateTask in the RKM's as a starting point), to create the CreateTask that hangs all the neccessary memory allocations off of the Task structure, and it's so elegant. Then the Task can just RemTask itself:) Patrick Horgan pjh70@zeus.ras.amdahl.com -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: mgooderum \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: markv@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~