Esempio n. 1
0
void floppy_prepare_motor_off(uint_t drive)
{
	if (drive >= MAX_DRIVES) {
		return;
	}
	if (floppy_drives[drive].motor_off_timer) {
		ktimer_stop(floppy_drives[drive].motor_off_timer);
		floppy_drives[drive].motor_off_timer = 0;
	}
	floppy_drives[drive].motor_off_timer = ktimer_start(floppy_motor_off_x[drive], 5000, 1);
}
Esempio n. 2
0
int main(int argc, char* argv[]) {
    int                i            = 0;
    kloop_t*            loop         = 0;
    ktimer_t*          timer        = 0;
    kchannel_ref_t*     connector    = 0;
    kthread_runner_t*   timer_thread = 0;
    static const char* helper_string =
        "-n    client count\n"
        "-ip   remote host IP\n"
        "-port remote host port\n";

    if (argc > 2) {
        for (i = 1; i < argc; i++) {
            if (!strcmp("-n", argv[i])) {
                client_n = atoi(argv[i+1]);
            } else if (!strcmp("-ip", argv[i])) {
                ip = argv[i+1];
            } else if (!strcmp("-port", argv[i])) {
                port = atoi(argv[i+1]);
            }
        }
    } else {
        printf(helper_string);
        exit(0);
    }

    loop       = knet_loop_create();
    timer_loop = ktimer_loop_create(1000);
    timer      = ktimer_create(timer_loop);

    ktimer_start(timer, timer_cb, 0, 1000);
    timer_thread = thread_runner_create(0, 0);
    thread_runner_start_timer_loop(timer_thread, timer_loop, 0);

    connector = knet_loop_create_channel(loop, 8, 121);
    knet_channel_ref_set_cb(connector, connector_cb);
    knet_channel_ref_set_timeout(connector, 1);
    if (error_ok != knet_channel_ref_connect(connector, ip, port, 20)) {
        return 0;
    }

    knet_loop_run(loop);
    thread_runner_destroy(timer_thread);
    knet_loop_destroy(loop);
    ktimer_loop_destroy(timer_loop);

    return 0;
}