Exemplo n.º 1
0
GraphCopySimple &GraphCopySimple::operator=(const GraphCopySimple &GC)
{
	NodeArray<node> vCopy;
	EdgeArray<edge> eCopy;

	Graph::assign(GC,vCopy,eCopy);
	initGC(GC,vCopy,eCopy);

	return *this;
}
Exemplo n.º 2
0
Widget::Widget(Monitor *monitor, Rectangle *rect, bool initWindowAndGC)
    : Rectangle(*rect)
{
    monitor_ = monitor;
    isVisible_ = false;
    if (initWindowAndGC) {
        initWindow();
        initGC();
    }
    else {
        window_ = 0;
        gc_ = 0;
    }
}
Exemplo n.º 3
0
Env* rvmStartup(Options* options) {
    // TODO: Error handling

    TRACE("Initializing logging");
    if (!rvmInitLog(options)) return NULL;

#if defined(IOS) && (defined(RVM_ARMV7) || defined(RVM_THUMBV7))
    // Enable IEEE-754 denormal support.
    // Without this the VFP treats numbers that are close to zero as zero itself.
    // See http://developer.apple.com/library/ios/#technotes/tn2293/_index.html.
    fenv_t fenv;
    fegetenv(&fenv);
    fenv.__fpscr &= ~__fpscr_flush_to_zero;
    fesetenv(&fenv);
#endif
    // print PID if it was requested
    if(options->printPID) {
        pid_t pid = getpid();
        if(options->pidFile) {
            FILE* f = fopen(options->pidFile, "w");
            if (!f) return NULL;
            fprintf(f, "%d", pid);
            fclose(f);
        } else {
            fprintf(stderr, "[DEBUG] %s: pid=%d\n", LOG_TAG, pid);
        }
    }

    // setup the TCP channel socket and wait
    // for the debugger to connect
    if(options->enableHooks) {
        if(!rvmHookSetupTCPChannel(options)) return NULL;
        if(!rvmHookHandshake(options)) return NULL;
    }

    TRACE("Initializing GC");
    if (!initGC(options)) return NULL;

    // Ignore SIGPIPE signals. SIGPIPE interrupts write() calls which we don't
    // want. Dalvik does this too in dalvikvm/Main.cpp.
    if (!ignoreSignal(SIGPIPE)) return NULL;

    // Ignore SIGXFSZ signals. SIGXFSZ is raised when writing beyond the RLIMIT_FSIZE
    // of the current process (at least on Darwin) using pwrite().
    if (!ignoreSignal(SIGXFSZ)) return NULL;

    VM* vm = rvmCreateVM(options);
    if (!vm) return NULL;

    Env* env = rvmCreateEnv(vm);
    if (!env) return NULL;
    // TODO: What if we can't allocate Env?

    if (!initClasspathEntries(env, options->resourcesPath, options->rawBootclasspath, &options->bootclasspath)) return NULL;
    if (!initClasspathEntries(env, options->resourcesPath, options->rawClasspath, &options->classpath)) return NULL;

    // Call init on modules
    TRACE("Initializing classes");
    if (!rvmInitClasses(env)) return NULL;
    TRACE("Initializing memory");
    if (!rvmInitMemory(env)) return NULL;
    TRACE("Initializing methods");
    if (!rvmInitMethods(env)) return NULL;
    TRACE("Initializing strings");
    if (!rvmInitStrings(env)) return NULL;
    TRACE("Initializing monitors");
    if (!rvmInitMonitors(env)) return NULL;
    TRACE("Initializing proxy");
    if (!rvmInitProxy(env)) return NULL;
    TRACE("Initializing threads");
    if (!rvmInitThreads(env)) return NULL;
    TRACE("Initializing attributes");
    if (!rvmInitAttributes(env)) return NULL;
    TRACE("Initializing primitive wrapper classes");
    if (!rvmInitPrimitiveWrapperClasses(env)) return NULL;
    TRACE("Initializing exceptions");
    if (!rvmInitExceptions(env)) return NULL;
    TRACE("Initializing signals");
    if (!rvmInitSignals(env)) return NULL;
    TRACE("Initializing JNI");
    if (!rvmInitJNI(env)) return NULL;

    // Initialize the RoboVM rt JNI code
//    RT_JNI_OnLoad(&vm->javaVM, NULL);
    // Initialize the dalvik rt JNI code
    TRACE("Initializing dalvik's runtime JNI code");
    registerCoreLibrariesJni((JNIEnv*) env);

#ifdef DARWIN
    TRACE("Initializing JAR NSURLProtocol");
    registerJARURLProtocol();
#endif

    TRACE("Creating system ClassLoader");
    systemClassLoader = rvmGetSystemClassLoader(env);
    if (rvmExceptionOccurred(env)) goto error_system_ClassLoader;
    env->currentThread->threadObj->contextClassLoader = systemClassLoader;

    TRACE("Initialization done");
    env->vm->initialized = TRUE;
    
    // Start Daemons
    TRACE("Starting Daemons");
    java_lang_Daemons = rvmFindClassUsingLoader(env, "java/lang/Daemons", NULL);
    if (!java_lang_Daemons) goto error_daemons;
    java_lang_Daemons_start = rvmGetClassMethod(env, java_lang_Daemons, "start", "()V");
    if (!java_lang_Daemons_start) goto error_daemons;
    rvmCallVoidClassMethod(env, java_lang_Daemons, java_lang_Daemons_start);
    if (rvmExceptionCheck(env)) goto error_daemons;
    TRACE("Daemons started");

    jboolean errorDuringSetup = FALSE;

    //If our options has any properties, let's set them before we call our main.
    if (options->properties) {
        //First, find java.lang.System, which has the setProperty method.
        Class* clazz = rvmFindClassUsingLoader(env, "java/lang/System", NULL);
        if (clazz) {
            //Get the setProperty method.
            Method* method = rvmGetClassMethod(env, clazz, "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
            if (method) {
                SystemProperty* property = options->properties;

                //Go through all of our properties and add each one in turn by calling setProperty.
                while (property != NULL) {
                    Object* key = NULL;
                    Object* value = NULL;
                    //The key is not allowed to be an empty string, so don't set it if we don't get a key.
                    if(property->key && strlen(property->key) > 0) {
                        key = rvmNewStringUTF(env, property->key, -1);
                    } else {
                        FATAL("Cannot have empty key in system property.");
                        errorDuringSetup = TRUE;
                        break;
                    }
                    if (property->value) {
                        value = rvmNewStringUTF(env, property->value, -1);
                    } else {
                        value = rvmNewStringUTF(env, "", -1);
                    }

                    if (key && value) {
                        rvmCallObjectClassMethod(env, clazz, method, key, value);
                    } else {
                        if (!key) {
                            FATALF("Error creating string from system property key: %s", property->key);
                        }
                        if (!value) {
                            FATALF("Error creating string from system property value: %s", property->value);
                        }
                        errorDuringSetup = TRUE;
                        break;
                    }
                    property = property->next; //Advance to the next property.
                }
            }
        }
    }

    return (errorDuringSetup) ? NULL : env;

error_daemons:
error_system_ClassLoader:
    rvmDetachCurrentThread(env->vm, TRUE, FALSE);

    return NULL;
}
Exemplo n.º 4
0
static void hpgl_begin_page(graph_t * g, point page, double scale, int rot,
			    point offset)
{
    char buffer[64];
    box clipWin;

    bufcnt = 0;
    Scale = scale;

    /* Initialize output */
    output(prefix);
    sprintf(buffer, "BP%sIN%s", Sep, Sep);
    output(buffer);
#ifdef SMILE
    doSmile();
#endif
#if 0				/* not used */
    initTextAlign();
#endif
    initGC();

    if (N_pages > 1) {
	saveGC();
	setFont(&coordFont);
	if (rot == 90) {
	    sprintf(buffer, "RO90IP%s", Sep);
	    output(buffer);
	}
	sprintf(buffer, "PA0,0%sLB(%d,%d)\03%s\n", Sep, page.x, page.y,
		Sep);
	output(buffer);
	if (rot == 90) {
	    sprintf(buffer, "ROIP%s", Sep);
	    output(buffer);
	}
	restoreGC();
    }

    if (rot == 90) {
	/* Rotate layout. HPGL/2 automatically shifts
	 * origin to bottom right corner, so we have to
	 * use the page width to set the new origin.
	 */
	sprintf(buffer, "RO90IP%s", Sep);
	output(buffer);

	clipWin.LL.x = PB.LL.y - HP_OY - 1;
	clipWin.LL.y = PageWidth - PB.UR.x - HP_OX - 1;
	clipWin.UR.x = PB.UR.y - HP_OY + 1;
	clipWin.UR.y = PageWidth - PB.LL.x - HP_OX + 1;
	Origin.x = PB.LL.y + scale * offset.y - HP_OY;
	Origin.y = PageWidth - PB.LL.x - scale * offset.x - HP_OX;
    } else {
	clipWin.LL.x = PB.LL.x - HP_OX - 1;
	clipWin.LL.y = PB.LL.y - HP_OY - 1;
	clipWin.UR.x = PB.UR.x - HP_OX + 1;
	clipWin.UR.y = PB.UR.y - HP_OY + 1;
	Origin.x = PB.LL.x + scale * offset.x - HP_OX;
	Origin.y = PB.LL.y + scale * offset.y - HP_OY;
    }
    /* Set clipping window */
    sprintf(buffer, "IW%d,%d,%d,%d%s\n",
	    (int) PT2UNIT(clipWin.LL.x), (int) PT2UNIT(clipWin.LL.y),
	    (int) PT2UNIT(clipWin.UR.x), (int) PT2UNIT(clipWin.UR.y), Sep);
    /* output(buffer); *//* Turn off clipping. */
    hpgl_set_scale(scale, scale);

}
Exemplo n.º 5
0
Env* rvmStartup(Options* options) {
    // TODO: Error handling

    TRACE("Initializing GC");
    if (!initGC(options)) return NULL;

    VM* vm = rvmCreateVM(options);
    if (!vm) return NULL;

    Env* env = rvmCreateEnv(vm);
    if (!env) return NULL;
    // TODO: What if we can't allocate Env?

    if (!initClasspathEntries(env, options->basePath, options->rawBootclasspath, &options->bootclasspath)) return NULL;
    if (!initClasspathEntries(env, options->basePath, options->rawClasspath, &options->classpath)) return NULL;

    // Call init on modules
    TRACE("Initializing logging");
    if (!rvmInitLog(env)) return NULL;
    TRACE("Initializing classes");
    if (!rvmInitClasses(env)) return NULL;
    TRACE("Initializing methods");
    if (!rvmInitMethods(env)) return NULL;
    TRACE("Initializing strings");
    if (!rvmInitStrings(env)) return NULL;
    TRACE("Initializing monitors");
    if (!rvmInitMonitors(env)) return NULL;
    TRACE("Initializing threads");
    if (!rvmInitThreads(env)) return NULL;
    TRACE("Initializing attributes");
    if (!rvmInitAttributes(env)) return NULL;
    TRACE("Initializing primitive wrapper classes");
    if (!rvmInitPrimitiveWrapperClasses(env)) return NULL;
    TRACE("Initializing exceptions");
    if (!rvmInitExceptions(env)) return NULL;
    TRACE("Initializing signals");
    if (!rvmInitSignals(env)) return NULL;
    TRACE("Initializing memory");
    if (!rvmInitMemory(env)) return NULL;

    // Initialize the RoboVM rt JNI code
//    RT_JNI_OnLoad(&vm->javaVM, NULL);
    // Initialize dalvik's JNIHelp code in libnativehelper
    TRACE("Initializing dalvik's libnativehelper");
    registerJniHelp((JNIEnv*) env);
    // Initialize the dalvik rt JNI code
    TRACE("Initializing dalvik's runtime JNI code");
    registerCoreLibrariesJni((JNIEnv*) env);

    TRACE("Creating system ClassLoader");
    systemClassLoader = rvmGetSystemClassLoader(env);
    if (rvmExceptionOccurred(env)) goto error_system_ClassLoader;
    env->currentThread->threadObj->contextClassLoader = systemClassLoader;

    TRACE("Initialization done");

    // Start Daemons
    TRACE("Starting Daemons");
    java_lang_Daemons = rvmFindClassUsingLoader(env, "java/lang/Daemons", NULL);
    if (!java_lang_Daemons) goto error_daemons;
    java_lang_Daemons_start = rvmGetClassMethod(env, java_lang_Daemons, "start", "()V");
    if (!java_lang_Daemons_start) goto error_daemons;
    rvmCallVoidClassMethod(env, java_lang_Daemons, java_lang_Daemons_start);
    if (rvmExceptionCheck(env)) goto error_daemons;
    TRACE("Daemons started");

    return env;

error_daemons:
error_system_ClassLoader:
    rvmDetachCurrentThread(env->vm, TRUE);

    return NULL;
}
Exemplo n.º 6
0
int main(int argc, char* argv[])
{
	Map map;
	Car cars[3] = {NULL, NULL, NULL};
	int x, y, i, rounds = 0, needPathfinding = 0, firstLoop = 1;
	List path;
	Position position;
	Vector acc;
	int fuel;

	srand(time(NULL));

	freopen("pshr4log.txt", "w+", stderr);
	// freopen("map.txt", "r", stdin);

	LOGINFO("Starting");

	initGC();

	map = Map_load(stdin);

	LOGINFO("Map loaded");

	while(!feof(stdin))
	{
		LOGINFO1I("===== Round number %d =====", rounds);

		for(i = 0; i < 3; i++)
		{
			fscanf(stdin, "%d %d", &x, &y);

			LOGINFO3I("Car number %i, position : %d %d", i, x, y);

			if(cars[i] == NULL)
				cars[i] = Car_new(x, y);
			else
				Car_updatePosition(cars[i], x, y);

			if(Car_updateArrivedStatus(cars[i], map))
			{
				recomputeDistances(map, cars);
				LOGINFO("I see you've arrived, let me see where I can park now...");
				needPathfinding = 1;
			}
		}

		if(firstLoop)
		{
			firstLoop = 0;
			path = doPathfinding(map, cars);
			List_tail(path);
			List_prev(path);
		}

		position = List_getCurrent(path);

		for(i = 1; i < 3; i++)
		{
			if(Position_equal(position, Car_getPosition(cars[i])))
			{
				needPathfinding = 1;
				LOGINFO("YOU TOOK MY SPOT JERK");
			}
		}

		if(needPathfinding)
		{
			freePath(path);
			path = doPathfinding(map, cars);
			List_tail(path);
			List_prev(path);
			needPathfinding = 0;
			position = List_getCurrent(path);
		}

		if(position == NULL)
		{
			goRandom();
		}
		else
		{
			LOGINFO2I("Going to %d %d", position->x, position->y);
			acc = Car_getAccelerationToReach(cars[0], position);
			go(acc->x, acc->y);

			if(Vector_squaredLength(acc) > 2)
			{
				Car_useBoost(cars[0]);
				LOGINFO("Using a boost");
			}

			Vector_delete(acc);
		}

		List_prev(path);

		rounds++;
	}

	LOGINFO("End");

	freePath(path);

	for(i = 0; i < 3; i++)
	{
		Car_delete(cars[i]);
	}

	Map_delete(map);
	freeGC();

	return 0;
}
Exemplo n.º 7
0
Arquivo: init.c Projeto: mpr90/robovm
Env* rvmStartup(Options* options) {
    // TODO: Error handling

#if defined(IOS) && (defined(RVM_ARMV7) || defined(RVM_THUMBV7))
    // Enable IEEE-754 denormal support.
    // Without this the VFP treats numbers that are close to zero as zero itself.
    // See http://developer.apple.com/library/ios/#technotes/tn2293/_index.html.
    fenv_t fenv;
    fegetenv(&fenv);
    fenv.__fpscr &= ~__fpscr_flush_to_zero;
    fesetenv(&fenv);
#endif

    TRACE("Initializing GC");
    if (!initGC(options)) return NULL;

    // Ignore SIGPIPE signals. SIGPIPE interrupts write() calls which we don't
    // want. Dalvik does this too in dalvikvm/Main.cpp.
    if (!ignoreSignal(SIGPIPE)) return NULL;

    // Ignore SIGXFSZ signals. SIGXFSZ is raised when writing beyond the RLIMIT_FSIZE
    // of the current process (at least on Darwin) using pwrite().
    if (!ignoreSignal(SIGXFSZ)) return NULL;

    VM* vm = rvmCreateVM(options);
    if (!vm) return NULL;

    Env* env = rvmCreateEnv(vm);
    if (!env) return NULL;
    // TODO: What if we can't allocate Env?

    if (!initClasspathEntries(env, options->basePath, options->rawBootclasspath, &options->bootclasspath)) return NULL;
    if (!initClasspathEntries(env, options->basePath, options->rawClasspath, &options->classpath)) return NULL;

    // Call init on modules
    TRACE("Initializing logging");
    if (!rvmInitLog(env)) return NULL;
    TRACE("Initializing classes");
    if (!rvmInitClasses(env)) return NULL;
    TRACE("Initializing memory");
    if (!rvmInitMemory(env)) return NULL;
    TRACE("Initializing methods");
    if (!rvmInitMethods(env)) return NULL;
    TRACE("Initializing strings");
    if (!rvmInitStrings(env)) return NULL;
    TRACE("Initializing monitors");
    if (!rvmInitMonitors(env)) return NULL;
    TRACE("Initializing proxy");
    if (!rvmInitProxy(env)) return NULL;
    TRACE("Initializing threads");
    if (!rvmInitThreads(env)) return NULL;
    TRACE("Initializing attributes");
    if (!rvmInitAttributes(env)) return NULL;
    TRACE("Initializing primitive wrapper classes");
    if (!rvmInitPrimitiveWrapperClasses(env)) return NULL;
    TRACE("Initializing exceptions");
    if (!rvmInitExceptions(env)) return NULL;
    TRACE("Initializing signals");
    if (!rvmInitSignals(env)) return NULL;

    // Initialize the RoboVM rt JNI code
//    RT_JNI_OnLoad(&vm->javaVM, NULL);
    // Initialize the dalvik rt JNI code
    TRACE("Initializing dalvik's runtime JNI code");
    registerCoreLibrariesJni((JNIEnv*) env);

    TRACE("Creating system ClassLoader");
    systemClassLoader = rvmGetSystemClassLoader(env);
    if (rvmExceptionOccurred(env)) goto error_system_ClassLoader;
    env->currentThread->threadObj->contextClassLoader = systemClassLoader;

    TRACE("Initialization done");
    env->vm->initialized = TRUE;
    
    // Start Daemons
    TRACE("Starting Daemons");
    java_lang_Daemons = rvmFindClassUsingLoader(env, "java/lang/Daemons", NULL);
    if (!java_lang_Daemons) goto error_daemons;
    java_lang_Daemons_start = rvmGetClassMethod(env, java_lang_Daemons, "start", "()V");
    if (!java_lang_Daemons_start) goto error_daemons;
    rvmCallVoidClassMethod(env, java_lang_Daemons, java_lang_Daemons_start);
    if (rvmExceptionCheck(env)) goto error_daemons;
    TRACE("Daemons started");

    return env;

error_daemons:
error_system_ClassLoader:
    rvmDetachCurrentThread(env->vm, TRUE, FALSE);

    return NULL;
}
void finishGC()
{
    while(1)
    {
        int completedBanks = 0;
        for (UINT32 bank=0; bank < NUM_BANKS; ++bank)
        {
            uart_print("bank "); uart_print_int(bank); uart_print(" ");
            switch (gcState[bank])
            {

                case GcIdle:
                {
                    if(cleanListSize(&cleanListDataWrite, bank) < 2)
                    { initGC(bank); }
                    else
                    { completedBanks++;}
                    break;
                }

                case GcRead:
                {
                    uart_print("read\r\n");
                    readPage(bank);
                    break;
                }

                case GcWrite:
                {
                    uart_print("write\r\n");
                    writePage(bank);
                    break;
                }

                default:
                {
                    uart_print_level_1("ERROR in garbageCollectLog: on bank "); uart_print_level_1_int(bank);
                    uart_print_level_1(", undefined GC state: "); uart_print_level_1_int(gcState[bank]); uart_print_level_1("\r\n");
                    while(1);
                }
            }
        }
        if (completedBanks == NUM_BANKS)
        {
            uart_print_level_1("GC Completed!\r\n");
            break;
        }
    }
#if PrintStats
    UINT32 totSparePages = 0;
    for (UINT32 bank=0; bank < NUM_BANKS; ++bank)
    {
        uart_print_level_1("FINALCNT ");
        uart_print_level_1_int(bank);
        uart_print_level_1(" ");
        uart_print_level_1_int(cleanListSize(&cleanListDataWrite, bank));
        uart_print_level_1(" ");
        uart_print_level_1_int(heapDataFirstUsage.nElInHeap[bank]);
        uart_print_level_1(" ");
        uart_print_level_1_int(heapDataSecondUsage.nElInHeap[bank]);
        uart_print_level_1(" ");
        uart_print_level_1_int(heapDataCold.nElInHeap[bank]);

        uart_print_level_1(" H ");

        UINT32 lpn = LogPageToOffset(hotLogCtrl[bank].logLpn);
        if (hotLogCtrl[bank].useRecycledPage)
        { // second usage, add the low pages
            lpn = lpn + 62;
        }
        else
        { // first usage, only low pages have been used
            lpn = (lpn/2)+1;
        }
        uart_print_level_1_int(lpn);
        totSparePages += LogPageToOffset(lpn);

        uart_print_level_1(" C ");
        lpn = coldLogCtrl[bank].logLpn;
        uart_print_level_1_int(LogPageToOffset(lpn));
        totSparePages += LogPageToOffset(lpn);
        uart_print_level_1("\r\n");
    }
    uart_print_level_1("TOTSPAREPAGES ");
    uart_print_level_1_int(totSparePages);
    uart_print_level_1("\r\n");

    for (UINT32 bank=0; bank < NUM_BANKS; ++bank)
    {
        uart_print_level_1("PARTIALLYUSEDTH ");
        uart_print_level_1_int(bank);
        uart_print_level_1(" ");
        uart_print_level_1_int(hotFirstAccumulated[bank]);
        uart_print_level_1("\r\n");
    }
#endif
}
void garbageCollectLog(const UINT32 bank_)
{

    //UINT32 firstBank = (bank_ / NUM_CHANNELS) * NUM_CHANNELS;
    //UINT32 lastBank = firstBank + NUM_CHANNELS;
    //UINT32 firstBank = bank_;
    //UINT32 lastBank = firstBank + 1;

    UINT32 banks[NUM_CHANNELS];

    for (UINT32 i=0; i<NUM_CHANNELS; ++i)
    {
        banks[i] = INVALID;
    }

#if PrintStats
    uart_print_level_1("Choose banks: ");
#endif
    for (UINT32 i=0; i<NUM_CHANNELS; ++i)
    {
#if PrintStats
        uart_print_level_1("i="); uart_print_level_1_int(i);
#endif
        if ((bank_ % NUM_CHANNELS) == i)
        {
#if PrintStats
            uart_print_level_1(" bank_ = "); uart_print_level_1_int(bank_); uart_print_level_1("; ");
#endif
            banks[i] = bank_;
        }
        else
        {
            UINT32 bank = (bank_/NUM_CHANNELS)*NUM_CHANNELS + i;
            for (UINT32 column=bank_/NUM_CHANNELS; column < NUM_BANKS/NUM_CHANNELS; ++column)
            {
#if PrintStats
                uart_print_level_1(" try bank = "); uart_print_level_1_int(bank);
#endif
                if (cleanListSize(&cleanListDataWrite, bank)<CleanBlksBackgroundGcThreshold)
                {
                    banks[i]=bank;
                    break;
                }
                else
                {
#if PrintStats
                    uart_print_level_1(" cl = "); uart_print_level_1_int(cleanListSize(&cleanListDataWrite, bank));
#endif
                    bank = (bank + NUM_CHANNELS) % NUM_BANKS;
                }
            }
#if PrintStats
            uart_print_level_1("; ");
#endif
        }
    }
#if PrintStats
            uart_print_level_1("\r\n");
#endif

#if PrintStats
    // note(fabio): if uncomment the if statement it will print Clean banks only when a new GC is started,
    //              otherwise print it also when GC is resumed after allocating new cold blk
    //if (gcState[bank_] == GcIdle)
    //{
        uart_print_level_1("Clean banks ");
        for (UINT32 i=0; i<NUM_CHANNELS; ++i)
        {
            if(banks[i] != INVALID)
            {
                uart_print_level_1_int(banks[i]);
                uart_print_level_1(" ");
            }
        }
        uart_print_level_1("\r\n");
    //}
#endif

    uart_print("garbageCollectLog bank_="); uart_print_int(bank_); uart_print("\r\n");

    for (UINT32 bankIdx=0; bankIdx < NUM_CHANNELS; ++bankIdx)
    {
        if (banks[bankIdx] != INVALID)
        {
            if (gcState[banks[bankIdx]] == GcIdle)
            {
                //start_interval_measurement(TIMER_CH2, TIMER_PRESCALE_0);
                initGC(banks[bankIdx]);
                //UINT32 timerValue=GET_TIMER_VALUE(TIMER_CH2);
                //UINT32 nTicks = 0xFFFFFFFF - timerValue;
                //uart_print_level_1("i "); uart_print_level_1_int(nTicks); uart_print_level_1("\r\n");
            }
        }
    }

    for (UINT32 bankIdx=0; bankIdx < NUM_CHANNELS; ++bankIdx)
    {
        if (banks[bankIdx] != INVALID)
        {
            if (gcState[banks[bankIdx]] == GcRead)
            {
                waitBusyBank(banks[bankIdx]);
            }
        }
    }

    while(1)
    {
        for (UINT32 bankIdx=0; bankIdx < NUM_CHANNELS; ++bankIdx)
        {
            uart_print("bankIdx "); uart_print_int(bankIdx); uart_print(" ");
            uart_print("bank "); uart_print_int(banks[bankIdx]); uart_print(" ");
            if (banks[bankIdx] != INVALID)
            {
                switch (gcState[banks[bankIdx]])
                {

                    case GcIdle:
                    {

                        uart_print("idle\r\n");

                        if (banks[bankIdx] == bank_)
                        {
                            return;
                        }
                        break;
                    }

                    case GcRead:
                    {
                        uart_print("read\r\n");
                        //start_interval_measurement(TIMER_CH2, TIMER_PRESCALE_0);
                        readPage(banks[bankIdx]);
                        //UINT32 timerValue=GET_TIMER_VALUE(TIMER_CH2);
                        //UINT32 nTicks = 0xFFFFFFFF - timerValue;
                        //uart_print_level_1("r "); uart_print_level_1_int(nTicks); uart_print_level_1("\r\n");
                        break;
                    }

                    case GcWrite:
                    {
                        uart_print("write\r\n");
                        //start_interval_measurement(TIMER_CH2, TIMER_PRESCALE_0);
                        writePage(banks[bankIdx]);
                        //UINT32 timerValue=GET_TIMER_VALUE(TIMER_CH2);
                        //UINT32 nTicks = 0xFFFFFFFF - timerValue;
                        //uart_print_level_1("w "); uart_print_level_1_int(nTicks); uart_print_level_1("\r\n");
                        break;
                    }

                    default:
                    {
                        uart_print_level_1("ERROR in garbageCollectLog: on bankIdx "); uart_print_level_1_int(bankIdx);
                        uart_print_level_1(" bank "); uart_print_level_1_int(banks[bankIdx]);
                        uart_print_level_1(", undefined GC state: "); uart_print_level_1_int(gcState[banks[bankIdx]]); uart_print_level_1("\r\n");
                        while(1);
                    }
                }
            }
        }
    }
}