void* kvfsd(void *arg) { uint_t tm_now, cntr; struct task_s *task; struct thread_s *this; struct cpu_s *cpu; struct alarm_info_s info; struct event_s event; uint_t fs_type; error_t err; cpu_enable_all_irq(NULL); printk(INFO, "INFO: Starting KVFSD on CPU %d [ %d ]\n", cpu_get_id(), cpu_time_stamp()); task = current_task; fs_type = VFS_TYPES_NR; #if CONFIG_ROOTFS_IS_EXT2 fs_type = VFS_EXT2_TYPE; #endif #if CONFIG_ROOTFS_IS_VFAT #if CONFIG_ROOTFS_IS_EXT2 #error More than one root fs has been selected #endif fs_type = VFS_VFAT_TYPE; #endif /* CONFIG_ROOTFS_IS_VFAT_TYPE */ err = vfs_init(__sys_blk, fs_type, VFS_MAX_NODE_NUMBER, VFS_MAX_FILE_NUMBER, &task->vfs_root); task->vfs_cwd = task->vfs_root; printk(INFO, "INFO: Virtual File System (VFS) Is Ready\n"); sysconf_init(); if(err == 0) { if((err = task_load_init(task))) { printk(WARNING, "WARNING: failed to load user process, err %d [%u]\n", err, cpu_time_stamp()); } } #if CONFIG_DEV_VERSION if(err != 0) { struct thread_s *thread; printk(INFO, "INFO: Creating kernel level terminal\n"); thread = kthread_create(task, &kMiniShelld, NULL, current_cluster->id, current_cpu->lid); thread->task = task; list_add_last(&task->th_root, &thread->rope); err = sched_register(thread); assert(err == 0); sched_add_created(thread); } #endif this = current_thread; cpu = current_cpu; event_set_senderId(&event, this); event_set_priority(&event, E_FUNC); event_set_handler(&event, &kvfsd_alarm_event_handler); info.event = &event; cntr = 0; while(1) { alarm_wait(&info, 10); sched_sleep(this); tm_now = cpu_time_stamp(); printk(INFO, "INFO: System Current TimeStamp %u\n", tm_now); sync_all_pages(); if((cntr % 4) == 0) dqdt_print_summary(dqdt_root); cntr ++; } return NULL; }
/* * int * main(int argc, char **argv) * Start routine of unc_dmctl command. */ int main(int argc, char **argv) { pfc_cmdopt_t *parser; cmdspec_t *spec; const char *conffile = UNCD_CONF_PATH; int argidx, ret; char c; /* Use C locale. */ (void)setlocale(LC_ALL, "C"); /* Set timezone. */ tzset(); /* Initialize signal. */ signal_init(); /* Create command line option parser. */ parser = pfc_cmdopt_init(PROGNAME, argc, argv, option_spec, arg_format, 0); if (PFC_EXPECT_FALSE(parser == NULL)) { fatal("Failed to create option parser."); /* NOTREACHED */ } while ((c = pfc_cmdopt_next(parser)) != PFC_CMDOPT_EOF) { switch (c) { case OPTCHAR_CONF: conffile = pfc_cmdopt_arg_string(parser); if (PFC_EXPECT_FALSE(*conffile == '\0')) { fatal("Configuration file path is empty."); /* NOTREACHED */ } break; case OPTCHAR_TIMEOUT: ipc_timeout = pfc_cmdopt_arg_uint32(parser); if (PFC_EXPECT_FALSE(ipc_timeout < IPC_TIMEOUT_MIN)) { fatal("-%c: Timeout value must be greater than " "or equal %u.", OPTCHAR_TIMEOUT, IPC_TIMEOUT_MIN); /* NOTREACHED */ } else if (PFC_EXPECT_FALSE(ipc_timeout > IPC_TIMEOUT_MAX)) { fatal("-%c: Timeout value must be less than " "or equal %u.", OPTCHAR_TIMEOUT, IPC_TIMEOUT_MAX); /* NOTREACHED */ } break; case OPTCHAR_CHANNEL: ipc_channel = pfc_cmdopt_arg_string(parser); if (PFC_EXPECT_FALSE(*ipc_channel == '\0')) { fatal("-%c: IPC channel name must not be " "empty.", OPTCHAR_CHANNEL); /* NOTREACHED */ } break; case OPTCHAR_DEBUG: debug_level++; break; case OPTCHAR_VERSION: dump_version(); /* NOTREACHED */ case PFC_CMDOPT_USAGE: pfc_cmdopt_usage(parser, stdout); exit(DMCTL_EX_OK); /* NOTREACHED */ case PFC_CMDOPT_HELP: pfc_cmdopt_help(parser, stdout, HELP_MESSAGE); exit(DMCTL_EX_OK); /* NOTREACHED */ case PFC_CMDOPT_ERROR: exit(DMCTL_EX_FATAL); /* NOTREACHED */ default: fatal("Failed to parse command line options."); /* NOTREACHED */ } } if ((argidx = pfc_cmdopt_validate(parser)) == -1) { fatal("Invalid command line options."); /* NOTREACHED */ } argc -= argidx; argv += argidx; if (argc == 0) { dump_subcommands(parser); /* NOTREACHED */ } pfc_cmdopt_destroy(parser); if (debug_level) { pfc_log_conf_t cf; pfc_log_level_t lvl = (debug_level == 1) ? PFC_LOGLVL_DEBUG : PFC_LOGLVL_VERBOSE; pfc_logconf_early(&cf, PFC_CFBLK_INVALID, PROGNAME, stderr, lvl, NULL); pfc_log_sysinit(&cf); } /* Determine subcommand. */ spec = subcmd_find(*argv); if (PFC_EXPECT_FALSE(spec == NULL)) { fatal("Unknown subcommand: %s", *argv); /* NOTREACHED */ } if (ipc_timeout == 0) { /* Use default timeout. */ ipc_timeout = spec->cs_timeout; } /* Load system configuration file. */ sysconf_init(conffile); if ((spec->cs_flags & CMDF_NOIPC) == 0) { int err; /* Initialize IPC client. */ err = ipc_init(); if (PFC_EXPECT_FALSE(err != 0)) { return DMCTL_EX_FATAL; } } /* Dispatch subcommand. */ current_cmd = spec; ret = spec->cs_func(spec, argc, argv); current_cmd = NULL; /* Tear down the command. */ if ((spec->cs_flags & CMDF_NOIPC) == 0) { ipc_fini(); } dmconf_cleanup(); return ret; }