team.c (1413B)
1 /* Copyright 1998-1999, Brian J. Swetland. All rights reserved. 2 ** Distributed under the terms of the OpenBLT License 3 */ 4 5 #include "kernel.h" 6 #include "memory.h" 7 #include "list.h" 8 9 team_t *team_create(void) 10 { 11 team_t *team = kmalloc(team_t); 12 13 if(!(team->aspace = aspace_create())) return NULL; 14 15 list_init(&team->resources); 16 team->refcount = 0; 17 team->text_area = 0; 18 team->heap_id = 0; 19 20 rsrc_bind(&team->rsrc, RSRC_TEAM, kernel_team); 21 rsrc_set_owner(&team->aspace->rsrc, team); 22 23 return team; 24 } 25 26 void team_destroy(team_t *team) 27 { 28 resource_t *rsrc; 29 30 // kprintf("death to team #%d (%s)",team->rsrc.id,team->rsrc.name); 31 // DEBUGGER(); 32 33 while(rsrc = list_remove_head(&team->resources)){ 34 rsrc->owner = NULL; 35 // kprintf("- %x %s %d",rsrc,rsrc_typename(rsrc),rsrc->id); 36 37 switch(rsrc->type){ 38 case RSRC_TASK: 39 kprintf("oops... cannot destroy team %d because of task %d!?", 40 team->rsrc.id,rsrc->id); 41 DEBUGGER(); 42 case RSRC_PORT: 43 port_destroy(rsrc->id); 44 break; 45 case RSRC_SEM: 46 sem_destroy(rsrc->id); 47 break; 48 case RSRC_ASPACE: 49 aspace_destroy((aspace_t*) rsrc); 50 break; 51 case RSRC_AREA: 52 case RSRC_QUEUE: 53 case RSRC_TEAM: 54 /* skip for now - teams don't get destroyed, areas and queues get 55 destroyed with their relatives */ 56 break; 57 58 default: 59 kprintf("what the hell is %d (type %d)?",rsrc->id,rsrc->type); 60 } 61 } 62 63 rsrc_release(team); 64 kfree(team_t, team); 65 } 66