Example #1
0
STATIC_INLINE StgPtr
thread_AP_STACK (StgAP_STACK *ap)
{
    thread(&ap->fun);
    thread_stack((P_)ap->payload, (P_)ap->payload + ap->size);
    return (P_)ap + sizeofW(StgAP_STACK) + ap->size;
}
Example #2
0
static StgPtr
thread_TSO (StgTSO *tso)
{
    thread_(&tso->link);

    if (tso->why_blocked == BlockedOnBlackHole) {
	thread_(&tso->block_info.closure);
    }
    
    thread_stack(tso->sp, &(tso->stack[tso->stack_size]));
    return (StgPtr)tso + tso_sizeW(tso);
}
Example #3
0
void
threads_init(void) 
{
  	int i;

	if (threads_initialized)
		return;	
	threads[0].thread = mach_thread_self();
	threads[0].stack = thread_stack(&i);
	set_thread_self(&threads[0]);
	threads_initialized = TRUE;
}
Example #4
0
static vm_offset_t
stack_alloc(vm_size_t size)
{
	vm_offset_t addr;
	vm_offset_t stack;
	vm_size_t unused;
	kern_return_t rc;

	if((rc = vm_allocate(mach_task_self(),
				  &addr,
				  2*STACK_SIZE,
				  TRUE)) != KERN_SUCCESS)
	{
		printf("stack_alloc: vm_allocate failed\n");
		return 0;
	}

	stack = thread_stack(addr+size-1);

	if ((unused = stack - addr)) {
		if((rc = vm_deallocate(mach_task_self(),
				  addr,
				  unused)) != KERN_SUCCESS) {
			printf("stack_alloc: vm_allocate failed\n");
			return 0;
		}
	}

	if ((unused = addr + size - stack)) {
		if((rc = vm_deallocate(mach_task_self(),
				  stack + size,
				  unused)) != KERN_SUCCESS) {
			printf("stack_alloc: vm_allocate failed\n");
			return 0;
		}
	}

	return(stack);
}
Example #5
0
/**
 * Destroy all thread_stack_nodes.
 */
void thread_stack_destroy_all()
{
    while(thread_stack() != NULL)
        thread_stack_destroy();
}