void DeleteTask ( /* SYNOPSIS */ struct Task * task) /* FUNCTION Get rid of a task which was created by CreateTask(). INPUTS task - The task which was created by CreateTask(). Must be non-NULL. RESULT None. NOTES EXAMPLE BUGS SEE ALSO exec.library/RemTask() INTERNALS HISTORY ******************************************************************************/ { RemTask (task); } /* DeleteTask */
/***************************************************************************** * * DeleteUnit * *****************************************************************************/ VOID DeleteUnit (struct DevUnit *unit, struct MyBase *base) { UBYTE i; struct Task *task; Debug ("\n DeleteUnit"); if (unit != NULL) { task = unit->task; if (task != NULL) { if (task->tc_SPLower != NULL) { RemTask (task); FreeMem (task->tc_SPLower, STACK_SIZE); } FreeMem (task, sizeof (struct Task)); } for (i = 0; i < REQUEST_QUEUE_COUNT; i ++) { if (unit->request_ports [i] != NULL) FreeMem (unit->request_ports [i], sizeof (struct MsgPort)); } // FreeVec(unit->tuple_buffer); FreeVec (unit->tx_buffer); FreeVec (unit->rx_buffer); FreeMem (unit, sizeof (struct DevUnit)); } return; }
static LONG open_con(struct conbase *conbase, struct IOFileSys *iofs) { struct filehandle *fh = (struct filehandle *)iofs->IOFS.io_Unit; STRPTR filename = iofs->io_Union.io_OPEN.io_Filename; #if DEBUG ULONG mode = iofs->io_Union.io_OPEN.io_FileMode; #endif struct conTaskParams params; struct Task *contask; LONG err = 0; EnterFunc(bug("open_conh(filename=%s, mode=%d)\n", filename, mode)); /* we're a console, we don't have a parent */ if (filename[0] == '/' && filename[1] == '\0') err = iofs->io_DosError = ERROR_OBJECT_NOT_FOUND; else if (fh != NULL && fh != (struct filehandle *)1) { /* DupLock */ fh->usecount++; } else { UBYTE sig = AllocSignal(-1); if (sig == (UBYTE)-1) { iofs->io_DosError = ERROR_NO_FREE_STORE; /* Any other error code better suited here? */ } else { params.conbase = conbase; params.iofs = iofs; params.parentTask = FindTask(NULL); params.initSignal = 1L << sig; contask = createConTask(¶ms, conbase); if (contask) { Wait(params.initSignal); if (iofs->io_DosError) { RemTask(contask); } } FreeSignal(sig); } err = iofs->io_DosError; } ReturnInt("open_conh", LONG, err); }
int main(int argc, char* argv[]) { struct MsgPort *port1; struct Task *t; port1=CreateMsgPort(); if(port1!=NULL) { port1->mp_Node.ln_Name="message test port"; Forbid(); if(FindPort(port1->mp_Node.ln_Name)==NULL) { AddPort(port1); Permit(); t=(struct Task *)AllocMem(sizeof(struct Task), MEMF_PUBLIC|MEMF_CLEAR); if(t!=NULL) { UBYTE *s; s=(UBYTE *)AllocMem(STACKSIZE, MEMF_PUBLIC|MEMF_CLEAR); if(s!=NULL) { t->tc_Node.ln_Type=NT_TASK; t->tc_Node.ln_Pri=1; t->tc_Node.ln_Name="new task"; t->tc_SPLower=s; t->tc_SPUpper=s+STACKSIZE; #if AROS_STACK_GROWS_DOWNWARDS t->tc_SPReg=(UBYTE *)t->tc_SPUpper-SP_OFFSET; #else t->tc_SPReg=(UBYTE *)t->tc_SPLower-SP_OFFSET; #endif NEWLIST(&t->tc_MemEntry); AddTask(t,&entry,NULL); Wait(1<<port1->mp_SigBit); if(port1->mp_MsgList.lh_Head->ln_Succ!=NULL) { int i; for(i=0;i<10;i++) { struct Message *msg; WaitPort(port1); msg=GetMsg(port1); printf("%d\n",(int)msg->mn_Node.ln_Name); ReplyMsg(msg); } Wait(1<<port1->mp_SigBit); RemTask(t); } FreeMem(s,STACKSIZE); } FreeMem(t,sizeof(struct Task)); } RemPort(port1); }else Permit(); DeleteMsgPort(port1); } return 0; }