int main(void){
  Heap_Init();
  Pt1 = Heap_Allocate();
  for(;;){
    Pt2 = Heap_Allocate();
    Pt3 = Heap_Allocate();
    Pt4 = Heap_Allocate();
    Pt5 = Heap_Allocate();
    Heap_Release(Pt4);
    Heap_Release(Pt3);
    Heap_Release(Pt2);
    Heap_Release(Pt5);
    count = count + 1;
  }
}
示例#2
0
文件: Kernel.c 项目: Astaelan/SEMOS
void Kernel(UINT32 pMBootMagic,
            PVOID pMBoot)
{
	COMPortLogger_Initialize();
	COMPortLogger_WriteLine("See? It works!");

	VGAText_Clear(VGATEXT_ATTRIBUTES(VGATEXT_ATTRIBUTE_LIGHT_WHITE, VGATEXT_ATTRIBUTE_DARK_BLACK));
	if (!MBoot_Initialize(pMBootMagic, pMBoot)) Panic("PANIC: Bootloader did not pass valid multiboot data");

    FileSystem_Initialize();

    printf("Booting SEMOS...\n");

	GDT_Initialize();
	IDT_Initialize();
	PIC_Initialize();
	PIT_Initialize(1000);
	RTC_Initialize();

	time_t startupTime = time(NULL);
	printf("Startup @ %s\n", ctime(&startupTime));

	SystemPartition_Initialize();

    printf("CLR Runtime Initializing\n");
	logLevel = 0;

    JIT_Execute_Init();
    printf("CLR JIT Initialized\n");
	MetaData_Init();
    printf("CLR MetaData Initialized\n");
	Type_Init();
    printf("CLR Types Initialized\n");
	Heap_Init();
    printf("CLR Heap Initialized\n");
	Finalizer_Init();
    printf("CLR Finalizer Initialized\n");

	tCLIFile *cliFile = CLIFile_Load("/SYSTEM/KERNEL.EXE");
    if (cliFile) printf("Loaded Kernel.exe\n");
	INT32 retValue = CLIFile_Execute(cliFile, 0, NULL);
    printf("Executed Kernel.exe: %d\n", retValue);
    if (retValue) { }
    while (TRUE);
}
示例#3
0
navpath_t* NavRep_PathCreate_Internal(navmesh_t* navmesh, const vec2_t src, navpoly_t* pathpoly_src, const vec2_t dest, navpoly_t* pathpoly_dest)
{
	int ms = System_Milliseconds();

	// increment the frame code (frame code is used in place of open/closed list)

	int frame = ++navmesh->frame_cnxn;

	if ( pathpoly_src == pathpoly_dest )
	{
		// if we're in the same pathpoly, just go there

		navpathwaypt_t* waypoint;

		path_last = (navpath_t*)ALLOCATE(navpath_t);
		path_last->waypoints.first = NULL;
		path_last->waypoints.last = NULL;
		M_CopyVec2(dest, path_last->pos);
		M_CopyVec2(dest, path_last->src);
		M_CopyVec2(src, path_last->dest);

		waypoint = NavPathWaypt_Create(src);
		waypoint->bridge = pathpoly_src->bridge2 ? pathpoly_src : NULL;
		List_PushFront(&path_last->waypoints, waypoint);

		path_last->waypoint = path_last->waypoints.first;
		
//		List_PushFront(&navpaths, path_last);

		return path_last;
	}

	if ( !pathpoly_dest->bridge2 && NavMesh_Trace(navmesh, src, dest) )
	{
		// if we can trace, just go there

		navpathwaypt_t* waypoint;

		path_last = (navpath_t*)ALLOCATE(navpath_t);
		path_last->waypoints.first = NULL;
		path_last->waypoints.last = NULL;
		M_CopyVec2(dest, path_last->pos);
		M_CopyVec2(dest, path_last->src);
		M_CopyVec2(src, path_last->dest);

		waypoint = NavPathWaypt_Create(src);
		List_PushFront(&path_last->waypoints, waypoint);

		path_last->waypoint = path_last->waypoints.first;

//		List_PushFront(&navpaths, path_last);

		return path_last;
	}

	{
		// create our heap

		heap_t heap;
		Heap_Init(&heap, 16384, Heap_Compare_PathPolyCnxn);

		// push all initial cnxns onto heap
		{
			navpolyedge_t* edge = pathpoly_src->edges;
			while ( edge )
			{
				navpolycnxn_t* cnxn = edge->cnxns.first;
				while ( cnxn )
				{
					navpolygate_t* gate = cnxn->gates;
					while ( gate )
					{
						// initialize costs

						gate->distance = path_sqrt(M_GetDistanceSqVec2(src, gate->position));
						gate->cost = gate->distance + path_sqrt(M_GetDistanceSqVec2(dest, gate->position));
						gate->from = NULL;
						gate->frame = frame;

						// add to heap

						Heap_Push(&heap, gate);

						gate = gate->next;
					}
				
					cnxn = cnxn->next;
				}

				edge = edge->next;
			}
		}

		while ( !Heap_IsEmpty(&heap) )
		{
			// extract min cost gate

			navpolygate_t* gate = (navpolygate_t*)Heap_Pop(&heap);
			if ( gate->cnxn->into == pathpoly_dest ) 
			{
				if ( fabs(gate->distance - gate->cost) < PATH_EPSILON )
				{
					// found a path, finalize it

					path_last = NavRep_PathFinalize(navmesh, src, dest, gate);

					NAV_PRINTF("NavRep_PathCreate succeeded, took %d milliseconds\n", System_Milliseconds() - ms);

					// term the heap

					Heap_Term(&heap);

//					List_PushFront(&navpaths, path_last);

					return path_last;
				}
				else
				{
					gate->distance += path_sqrt(M_GetDistanceSqVec2(gate->position, dest));
					gate->cost = gate->distance;

					Heap_Update(&heap, gate);
					
					continue;
				}
			}

			// relax all adjacent gates
			{
				navpoly_t* pathpoly = gate->cnxn->into;
				navpolyedge_t* pathpoly_edge = pathpoly->edges;
				while ( pathpoly_edge )
				{
					navpolycnxn_t* pathpoly_cnxn = pathpoly_edge->cnxns.first;
					while ( pathpoly_cnxn )
					{
						navpolygate_t* pathpoly_gate = pathpoly_cnxn->gates;
						while ( pathpoly_gate )
						{
							float distance = 1.0f + gate->distance + path_sqrt(M_GetDistanceSqVec2(pathpoly_gate->position, gate->position));
							float cost = distance + path_sqrt(M_GetDistanceSqVec2(pathpoly_gate->position, dest));

							if ( pathpoly_gate->frame != frame )
							{
								pathpoly_gate->cost = cost;
								pathpoly_gate->distance = distance;
								pathpoly_gate->frame = frame;
								pathpoly_gate->from = gate;

								Heap_Push(&heap, pathpoly_gate);
							}
							// $todo: why is it okay (faster + just as accurate) to compare distance here rather than cost????
							else if ( (pathpoly_gate->distance > distance) )
							{
								pathpoly_gate->cost = cost;
								pathpoly_gate->distance = distance;
								pathpoly_gate->from = gate;

								Heap_Update(&heap, pathpoly_gate);
							}

							pathpoly_gate = pathpoly_gate->next;
						}

						pathpoly_cnxn = pathpoly_cnxn->next;
					}

					pathpoly_edge = pathpoly_edge->next;
				}
			}
		}

		NAV_PRINTF("NavRep_PathCreate failed, took %d milliseconds\n", System_Milliseconds() - ms);

		// term the heap

		Heap_Term(&heap);
	}

	return NULL;
}
示例#4
0
NOINLINE void scalanative_init() {
    Heap_Init(&heap, Settings_MinHeapSize(), Settings_MaxHeapSize());
    Stack_Init(&stack, INITIAL_STACK_SIZE);
    atexit(scalanative_afterexit);
}