void kmain(void) { init_bss(); init_ro(); setup_kernel_memory(); setup_pages(); setup_ints(); setup_tss(); setup_paging(); setup_faults(); setup_fs(); setup_syscalls(); init_devs(); char vendor[12]; if (has_cpuid()) { cpuid_string(0, vendor); dprintf("CPU Vendor ID: %s\n"); } fexec("/prgm/start", 0, NULL, NULL); start_scheduler(); asm volatile ("sti"); asm volatile ("hlt"); /* We should never reach this */ assert(0); }
/* * Function: main * Parameter(s): built in parameters that has command line arguments stored in it. * Returns: exit status of the program * Description: The main controller of the whole program, * connects with other functions and accomplishes the given task. */ int main(int argc, char* argv[]) { read_args(argc, argv); read_jobs(); start_scheduler(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { create_ctx(16384, f_ping, NULL); create_ctx(16384, f_pong, NULL); create_ctx(16384, f_pung, NULL); start_scheduler(); exit(EXIT_SUCCESS); }
struct flim * flm_new() { flim = malloc(sizeof(struct flim)); initialize_js(flim); flim->scheduler = create_scheduler(flim->js_context); start_scheduler(flim->scheduler); flim->output = create_midi_out(); return flim; }
void TrexStatelessDpCore::run_once(){ idle_state_loop(); if ( m_state == STATE_TERMINATE ){ return; } start_scheduler(); }
//----------------------------------------------------------------------------- int notmain ( void ) { create_process( turn_led_off ); create_process( play_music ); start_scheduler(); return 0; }
int kernel_main (void) { puts("This is ninjastorms OS"); puts(" shuriken ready"); add_task(&controller_task); start_scheduler(); puts("All done. ninjastorms out!"); return 0; }
int main() { struct rlimit rl; rl.rlim_max = rl.rlim_cur = 1024*64; if (setrlimit(RLIMIT_NOFILE, &rl) < -1) { return -1; } fiber_mutex_init(&mtx); memset((char*)sharedArr, 0, 64); const char *server_ip = "127.0.0.1"; struct Scheduler *sch = create_scheduler(8); if (sch == NULL) return 0; struct TcpServer *server = create_tcp_server(server_ip, 12400, data_processor); if (server == NULL) return 0; start_scheduler(sch); run_tcp_server(sch, server); return 0; }
int main(int argc, char const *argv[]) { switch_on_hse(); construct_exceptions(); construct_nvic(); construct_systick(); construct_scheduler(); construct_app(); construct_rcc(); construct_gpio(); construct_tim14(); start_exceptions(); start_nvic(); start_systick(); start_rcc(); start_gpio(); start_tim14(); start_app(); /* must be last */ start_scheduler(); }
//----------------------------------------------------------------------------- int notmain ( void ) { //init_ctx(&ctx_A, funcA, STACK_SIZE); //init_ctx(&ctx_B, funcB, STACK_SIZE); //current_ctx = &ctx_init; //switch_to(&ctx_A); create_process(funcA, 0); create_process(funcB, 0); start_scheduler(); // int i; // for( i=0; i<5; i++) // { // chopsticks[i] = mtx_init(); // create_process( philosopher, i ); // } // // start_scheduler(); return 0; }
int server_start(char *host, char *service, int daemonize, int *pid) { struct addrinfo hints, *servinfo; struct sockaddr_storage their_addr; socklen_t addr_size; int status; int yes=1; int errsv; int conn; int havelock = 0; int lockfd; char buf[sizeof(long)]; memset(&hints, 0, sizeof hints); /* zero memory */ hints.ai_family = AF_UNSPEC; /* ipv4/ipv6 agnostic */ hints.ai_socktype = SOCK_STREAM; /* TCP stream sockets */ hints.ai_flags = AI_PASSIVE; /* ips we can bind to */ /* obtain lockfile */ if ((havelock = obtain_lockfile(&lockfd)) != 0) exit(havelock); if ((status = getaddrinfo(NULL, service, &hints, &servinfo)) != 0){ fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status)); freeaddrinfo(servinfo); return -1; } /* get a socket */ sock = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol); /* reuse socket if already in use */ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); /* bind to a port */ bind(sock, servinfo->ai_addr, servinfo->ai_addrlen); freeaddrinfo(servinfo); /* listening */ if (listen(sock, BACKLOG) != 0) { errsv = errno; fprintf(stderr, "ERROR: %s\n", strerror(errsv)); return -1; } memset(&their_addr, 0, sizeof(their_addr)); memset(&addr_size, 0, sizeof(addr_size)); /* daemonize */ if (daemonize) { p = fork(); if (p == -1) { /* fork() failed */ errsv = errno; fprintf(stderr, "ERROR: %s\n", strerror(errsv)); return -1; } else if (p !=0) { /* parent process returns pid to caller */ *pid = p; return 0; } /* create new session */ if (setsid() == -1) { errsv = errno; fprintf(stderr, "ERROR: %s\n", strerror(errsv)); return -1; } /* change working directory */ if (chdir("/") == -1) { errsv = errno; fprintf(stderr, "ERROR: %s\n", strerror(errsv)); return -1; } /* set umask */ umask(0); /* open syslog */ openlog(PROGRAM, LOG_CONS|LOG_PID, LOG_DAEMON); /* redirect st{in,out,err} */ close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); if (open("/dev/null", O_RDONLY) == -1) { syslog(LOG_ERR, "Failed to redirect stdin"); _exit(EXIT_FAILURE); } if (open("/dev/null", O_WRONLY) == -1) { syslog(LOG_ERR, "Failed to redirect stdout"); _exit(EXIT_FAILURE); } if (open("/dev/null", O_RDWR) == -1) { syslog(LOG_ERR, "Failed to redirect stderr"); _exit(EXIT_FAILURE); } syslog(LOG_DEBUG, "Daemon started"); } /* write pid to lockfile */ snprintf(buf, sizeof(long), "%ld\n", (long) getpid()); if (write(lockfd, buf, strlen(buf)) != strlen(buf)) { fprintf(stderr, "Error writing to pidfile\n"); exit(EXIT_FAILURE); } /* fork() scheduler process */ if (start_scheduler() != 0) { fprintf(stderr, "Failed to start scheduler\n"); exit(EXIT_FAILURE); } for (;;) { conn = accept(sock, (struct sockaddr *)&their_addr,&addr_size); /* fork to handle connection */ p = fork(); if (p == -1) { /* fork() failed */ errsv = errno; fprintf(stderr, "ERROR: %s\n", strerror(errsv)); return -1; } else if (p == 0) { /* child */ close(sock); /* children don't listen */ handle_connection(conn); } close(conn); /* parent closes connection */ ++hits; /* increment hit counter */ } return 0; }
void start_kernel(void) { char str[] = "C FUNCTION START!"; /* * ARCHITECTURE DEPENDENT INITIALIZATIONS */ /* screen - message display */ init_screen(); caos_printf("%s\n", str); /* memory manager */ setup_memory(); /* exception & interrupt */ init_idt(); set_idtr(); /* device & IRQ */ init_char_dev(); keyboard_init(); init_timer(); /* scheduling */ init_scheduler(); /* task management */ setup_task(); init_cpu_tss(); /* after task setup, start scheduler */ start_scheduler(); /*************************************************/ /* * ARCHITECTURE INDEPENDENT PROCESSING */ if (create_task(init, "init") < 0) caos_printf("Create Init fail..\n"); if (create_task(user1, "user1") < 0) caos_printf("Create user1 fail..\n"); if (create_task(user2, "user2") < 0) caos_printf("Create user2 fail..\n"); caos_printf("CaOS KERNEL END!!\n"); /* execute user mode task */ start_init(); while (1); }
/* This the actual main() of rmlint */ void start_processing(lint_t *b) { file_group *fglist = NULL, emptylist; char lintbuf[128]; char suspbuf[128]; nuint_t ii = 0, lint = 0, spelen = 0, rem_counter = 0, suspicious = 0, path_doubles = 0; if(set->namecluster) { find_double_bases(b); error("\n"); } emptylist.len = 1; emptylist.size = 0; /* Split into groups, based by size */ while(b) { lint_t *q = b, *prev = NULL; nuint_t glen = 0, gsize = 0; while(b && q->fsize == b->fsize) { prev = b; if(b->dupflag == false) { b->dupflag = true; } gsize += b->fsize; glen++; b = b->next; } if(glen == 1) { /* This is only a single element */ /* We can remove it without feelind bad */ q = list_remove(q); if(b != NULL) { b = q; } rem_counter++; } else { /* Mark this isle as 'sublist' by setting next/last pointers */ if(b != NULL) { prev->next = NULL; b->last = NULL; } if(q->fsize != 0) { /* Sort by inode (speeds up IO on normal HDs [not SSDs]) */ q = list_sort(q,cmp_nd); /* Add this group to the list array */ fglist = realloc(fglist, (spelen+1) * sizeof(file_group)); fglist[spelen].grp_stp = q; fglist[spelen].grp_enp = prev; fglist[spelen].len = glen; fglist[spelen].size = gsize; /* Remove 'path-doubles' (files pointing to the physically SAME file) - this requires a node sorted list */ if((set->followlinks && get_cpindex() == 1) || get_cpindex() > 1) path_doubles += rm_double_paths(&fglist[spelen]); /* number_of_groups++ */ spelen++; } else /* this is some other sort of lint (indicated by a size of 0) */ { lint_t *ptr; char flag = 42; bool e_file_printed = false; const char * chown_cmd = " chown $(whoami):$(id -gn)"; q = list_sort(q,cmp_nd); emptylist.grp_stp = q; if((set->followlinks && get_cpindex() == 1) || get_cpindex() > 1) rm_double_paths(&emptylist); /* sort by lint_ID (== dupID) */ ptr = emptylist.grp_stp; ptr = list_sort(ptr,cmp_sort_dupID); emptylist.grp_stp = ptr; emptylist.len = 0; while(ptr) { if(flag != ptr->dupflag) { if(set->verbosity > 1) { error(YEL"\n#"NCO); } else { error("\n#"); } /* -- */ if(ptr->dupflag == TYPE_BLNK) { error(" Bad link(s): \n"); } else if(ptr->dupflag == TYPE_OTMP) { error(" Old Tempfile(s): \n"); } else if(ptr->dupflag == TYPE_EDIR) { error(" Empty dir(s): \n"); } else if(ptr->dupflag == TYPE_JNK_DIRNAME) { error(" Junk dirname(s): \n"); } else if(ptr->dupflag == TYPE_JNK_FILENAME) { error(" Junk filename(s): \n"); } else if(ptr->dupflag == TYPE_NBIN) { error(" Non stripped binarie(s): \n"); } else if(ptr->dupflag == TYPE_BADUID) { error(" Bad UID: \n"); } else if(ptr->dupflag == TYPE_BADGID) { error(" Bad GID: \n"); } else if(ptr->fsize == 0 && e_file_printed == false) { error(" Empty file(s): \n"); e_file_printed = true; } flag = ptr->dupflag; } if(set->verbosity > 1) { error(GRE); } if(ptr->dupflag == TYPE_BLNK) { error(" rm"); } else if(ptr->dupflag == TYPE_OTMP) { error(" rm"); } else if(ptr->dupflag == TYPE_EDIR) { error(" rmdir"); } else if(ptr->dupflag == TYPE_JNK_DIRNAME) { error(" ls"); } else if(ptr->dupflag == TYPE_JNK_FILENAME) { error(" ls"); } else if(ptr->dupflag == TYPE_NBIN) { error(" strip --strip-debug"); } else if(ptr->dupflag == TYPE_BADUID) { error(chown_cmd); } else if(ptr->dupflag == TYPE_BADGID) { error(chown_cmd); } else if(ptr->fsize == 0) { error(" rm"); } if(set->verbosity > 1) { error(NCO); } error(" %s\n",ptr->path); if(set->output) { write_to_log(ptr, false,NULL); } emptylist.size += ptr->fsize; ptr = list_remove(ptr); emptylist.len++; } } } } error("\n"); if(set->searchdup == 0) { nuint_t i = 0; /* rmlint was originally supposed to find duplicates only So we have to free list that whould have been used for dup search before dieing */ for(; i < spelen; i++) { list_clear(fglist[i].grp_stp); } if(fglist) { free(fglist); } die(0); } info("\nNow attempting to find duplicates. This may take a while...\n"); info("Now removing files with unique sizes from list..."); info(""YEL"%ld item(s) less"NCO" in list.",rem_counter); if(path_doubles) { info(" (removed "YEL"%ld pathzombie(s)"NCO")", path_doubles); } info(NCO"\nNow removing "GRE"%ld"NCO" empty files / bad links / junk names from list...\n"NCO, emptylist.len); info("Now sorting groups based on their location on the drive..."); /* Now make sure groups are sorted by their location on the disk*/ qsort(fglist, spelen, sizeof(file_group), cmp_grplist_bynodes); info(" done. \nNow doing fingerprints and full checksums.%c\n",set->verbosity > 4 ? '.' : '\n'); db_done = true; error("%s Duplicate(s):",(set->verbosity > 1) ? YEL"#"NCO : "#"); /* Groups are splitted, now give it to the scheduler * The scheduler will do another filterstep, build checkusm * and compare 'em. The result is printed afterwards */ start_scheduler(fglist, spelen); if(get_dupcounter() == 0) { error("\r "); } else { error("\n"); } /* Gather the total size of removeable data */ for(ii=0; ii < spelen; ii++) { if(fglist[ii].grp_stp != NULL) { lint += fglist[ii].size; } } /* now process the ouptput we gonna print */ size_to_human_readable(lint, lintbuf, 127 /* bufsize */); size_to_human_readable(emptylist.size, suspbuf, 127); /* Now announce */ warning("\n"RED"=> "NCO"In total "RED"%llu"NCO" files, whereof "RED"%llu"NCO" are duplicate(s)",get_totalfiles(), get_dupcounter()); suspicious = emptylist.len + dbase_ctr; if(suspicious > 1) { warning(RED"\n=> %llu"NCO" other suspicious items found ["GRE"%s"NCO"]",emptylist.len + dbase_ctr,suspbuf); } warning("\n"); if(!iAbort) { warning(RED"=> "NCO"Totally "GRE" %s "NCO" [%llu Bytes] can be removed.\n", lintbuf, lint); } if((set->mode == 1 || set->mode == 2) && get_dupcounter()) { warning(RED"=> "NCO"Nothing removed yet!\n"); } warning("\n"); if(set->verbosity == 6) { info("Now calculation finished.. now writing end of log...\n"); info(RED"=> "NCO"In total "RED"%llu"NCO" files, whereof "RED"%llu"NCO" are duplicate(s)\n",get_totalfiles(), get_dupcounter()); if(!iAbort) { info(RED"=> "NCO"In total "GRE" %s "NCO" ["BLU"%llu"NCO" Bytes] can be removed without dataloss.\n", lintbuf, lint); } } if(get_logstream() == NULL && set->output) { error(RED"\nERROR: "NCO); fflush(stdout); perror("Unable to write log"); putchar('\n'); } else if(set->output) { warning("A log has been written to "BLU"%s.log"NCO".\n", set->output); warning("A ready to use shellscript to "BLU"%s.sh"NCO".\n", set->output); } /* End of actual program. Now do some finalizing */ if(fglist) { free(fglist); } }