int main(const int argc, const char *argv[]) { char buf[BUFFER_MAX]; struct sockaddr addr; socklen_t alen; int lsocket, s, count; if (initialize_globals() < 0) { LOGE("Could not initialize globals; exiting.\n"); exit(1); } if (initialize_directories() < 0) { LOGE("Could not create directories; exiting.\n"); exit(1); } lsocket = android_get_control_socket(SOCKET_PATH); if (lsocket < 0) { LOGE("Failed to get socket from environment: %s\n", strerror(errno)); exit(1); } if (listen(lsocket, 5)) { LOGE("Listen on socket failed: %s\n", strerror(errno)); exit(1); } fcntl(lsocket, F_SETFD, FD_CLOEXEC); for (;;) { alen = sizeof(addr); s = accept(lsocket, &addr, &alen); if (s < 0) { LOGE("Accept failed: %s\n", strerror(errno)); continue; } fcntl(s, F_SETFD, FD_CLOEXEC); LOGI("new connection\n"); for (;;) { unsigned short count; if (readx(s, &count, sizeof(count))) { LOGE("failed to read size\n"); break; } if ((count < 1) || (count >= BUFFER_MAX)) { LOGE("invalid size %d\n", count); break; } if (readx(s, buf, count)) { LOGE("failed to read command\n"); break; } buf[count] = 0; if (execute(s, buf)) break; } LOGI("closing connection\n"); close(s); } return 0; }
SEXP dieharderCallback(SEXP callback_sexp, SEXP bits_sexp, SEXP testnum_sexp, SEXP seed_sexp, SEXP psamples_sexp, SEXP tsamples_sexp, SEXP ntuple_sexp, SEXP quiet_sexp, SEXP verbose_sexp) { initialize_globals(bits_sexp, seed_sexp, ntuple_sexp, quiet_sexp, verbose_sexp); Dtest *test_type = dh_test_types[INTEGER_VALUE(testnum_sexp)]; Test **test_results = create_test(test_type, INTEGER_VALUE(tsamples_sexp), INTEGER_VALUE(psamples_sexp)); global_parsed_callback = parse_and_test_callback(callback_sexp); if (global_parsed_callback) { PROTECT(global_parsed_callback); std_test(test_type, test_results); UNPROTECT(1); } else { result = NULL; } global_parsed_callback = NULL; output(test_type, test_results); save_values_for_R(test_type, test_results); destroy_test(test_type, test_results); gsl_rng_free(rng); rng = NULL; reset_bit_buffers(); return result; }
int main(int argc, char *argv[]) { initialize_globals(); create_output_dirs(); RiverModel model; Configuration config; config.read("./data/testconfig.conf"); model.setConfiguration(config); model.run(); return 0; }
PCSC_API LONG SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) { if (!phContext) return SCARD_E_INVALID_PARAMETER; if (!context_count) initialize_globals(); context_count++; *phContext = validhandle; return SCARD_S_SUCCESS; }
static int installd_main(const int argc ATTRIBUTE_UNUSED, char *argv[]) { int ret; int selinux_enabled = (is_selinux_enabled() > 0); setenv("ANDROID_LOG_TAGS", "*:v", 1); android::base::InitLogging(argv); SLOGI("installd firing up"); union selinux_callback cb; cb.func_log = log_callback; selinux_set_callback(SELINUX_CB_LOG, cb); if (!initialize_globals()) { SLOGE("Could not initialize globals; exiting.\n"); exit(1); } if (initialize_directories() < 0) { SLOGE("Could not create directories; exiting.\n"); exit(1); } if (selinux_enabled && selinux_status_open(true) < 0) { SLOGE("Could not open selinux status; exiting.\n"); exit(1); } if ((ret = InstalldNativeService::start()) != android::OK) { SLOGE("Unable to start InstalldNativeService: %d", ret); exit(1); } IPCThreadState::self()->joinThreadPool(); LOG(INFO) << "installd shutting down"; return 0; }
int main (int argc, char* argv[]) { char filename1[200]; char filename2[200]; char pairs_file[200]; char fileout[200]; FILE* query_fp = 0; FILE* reference_fp = 0; FILE* fp_pairs = 0; FILE* fpout = stdout; int total_pairs = 0; pair_struct* pairs = 0; extern FILE *scaninfo_file; setup_match_types(); /* Set Default Parameter Values*/ length_5p_for_weighting = 8; /* The 5' sequence length to be weighted except for the last residue */ scale = 4.0; /* The 5' miRNA scaling parameter */ strict = 0; /* Strict seed model on/off*/ debug = 0; /* Debugging mode on/off*/ key_value_pairs = 0; gap_open = -9.0; /* Gap-open Penalty*/ gap_extend = -4.0; /* Gap-extend Penalty*/ score_threshold = 140.0; /* SW Score Threshold for reporting hits*/ score_ceiling = 0; /* Default upper limit to score. If zero, this is not used. */ energy_threshold = 1.0; /* Energy Threshold (DG) for reporting hits*/ verbosity = 1; /* Verbose mode on/off*/ brief_output = 0; /* Brief output off by default */ rusage_output = 0; /* rusage output off by default */ outfile = 0; /* Dump to file on/off*/ truncated = 0; /* Truncate sequences on/off*/ no_energy = 1; /* Turn off Energy Calcs - FASTER*/ restricted = 0; /* Perform restricted search space*/ parse_command_line(argc, argv, filename1, filename2, fileout, pairs_file); if (gap_open > 0.0 || gap_extend > 0.0) { fprintf(stderr, "Error: gap penalties may not be greater than 0\n"); return 1; } if (truncated < 0) { fprintf(stderr, "Error: negative value give for UTR truncation\n"); return 1; } if ((query_fp = fopen(filename1, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename1); return 1; } if ((reference_fp = fopen(filename2, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename2); return 1; } fclose(reference_fp); if ((outfile) && ((fpout = fopen(fileout, "w")) == NULL)) { fprintf(stderr, "Error: Cannot create output file %s\n", fileout); return 1; } if (restricted) { if ((fp_pairs = fopen(pairs_file, "r")) == NULL) { fprintf(stderr, "Error: Cannot open restrict pairs file %s\n", pairs_file); return 1; } /* Initialize the pairs list for restriced searches*/ total_pairs = load_pairs(fp_pairs, &pairs); fclose(fp_pairs); } fflush(fpout); initialize_globals(); if(!brief_output) print_parameters(filename1, filename2, fpout); if (restricted && verbosity) { printf("Performing Restricted Scan on:%d pairs\n", total_pairs); } find_targets(query_fp, fpout, pairs, total_pairs, filename2); #ifdef USE_RUSAGE if(rusage_output) { struct rusage ru; if(getrusage(RUSAGE_SELF,&ru) != 0) { fprintf(stderr,"Could not get rusage data\n"); if(errno) fprintf(stderr,"Reason: %s",strerror(errno)); } else { printf("User CPU time: %ld.%06ld\n",ru.ru_utime.tv_sec,ru.ru_utime.tv_usec); printf("Max RSS: %ld KB\n",ru.ru_maxrss); } } #endif // RUSAGE destroy_globals(); if (outfile) fclose(fpout); if (scaninfo_file != stdout && scaninfo_file != stderr && scaninfo_file != NULL) fclose(scaninfo_file); json_close(); fclose(query_fp); return 0; }
int main() { // boolean values bool needToExecuteProgram, extendVariable, extendAtBack, extendAtFront, didComplete, checkAlias; // counters int wordCount, loopCount, tempCount, arrayPosition_x, arrayPosition_y; // strings char commandInput[100],tempWord[20],userCommand[10][30], temp[50], temp2[50], temp3[50]; // commands & variables char *command, *arg1, *arg2, *arg3, *extending; // declare list heads struct node *varHP; struct node *aliasHP; // init to null varHP = NULL; aliasHP = NULL; char mem[1000]; initialize_globals(mem, 1000); memset(mem, 0, 1000); //all values need to be initialized to 0. // get command input needToExecuteProgram = TRUE; while (needToExecuteProgram) { // print shell prompt wordCount = 0; prompt; fgets(commandInput, 100, stdin); // For @var to display if(commandInput[0] == '@') { int temporary = strlen(commandInput) -2; //to ignore "@" and "\n" in input char temporary2[temporary]; int x = 1,y = 0;; //skip the @ while(y < temporary) { if(commandInput[x] == '\n') //break at the newline, we don't want that included break; temporary2[y] = commandInput[x]; x++; //temporary[2] will hold the variable name. y++; } temporary2[y] = '\0'; nshFind(varHP, temporary2); continue; } //end of @var display // break up input string from user into an array of strings to interpret tempCount = arrayPosition_x = arrayPosition_y = 0; // loop through each character of the string entered from the command line for (loopCount=0; loopCount<strlen(commandInput)-1; loopCount++) { // if a space is found if (commandInput[loopCount] == space) { // end the temp word tempWord[tempCount] = EOS; // place it in the command array arrayPosition_y = 0; wordCount++; while (TRUE) { if (tempWord[arrayPosition_y] == EOS) { userCommand[arrayPosition_x][arrayPosition_y] = EOS; break; } userCommand[arrayPosition_x][arrayPosition_y] = tempWord[arrayPosition_y]; arrayPosition_y++; } // move to get the next word arrayPosition_x++; tempCount = 0; } // while there are no spaces else { // put the characters in a temporary word until one is found tempWord[tempCount] = commandInput[loopCount]; tempCount++; // if there is no space, but its the end of the user's input if (loopCount == strlen(commandInput)-2) { tempWord[tempCount] = EOS; arrayPosition_y = 0; wordCount++; while (TRUE) { if (tempWord[arrayPosition_y] == EOS) { userCommand[arrayPosition_x][arrayPosition_y] = EOS; break; } userCommand[arrayPosition_x][arrayPosition_y] = tempWord[arrayPosition_y]; arrayPosition_y++; } } } } // Implement whatever command was given or print the errors // if there was input if (wordCount > 0) { // get the command command = &userCommand[0][0]; // if the command is "set" if (strcmp(command,"set") == 0 || (matchAlias(aliasHP, "set", command))==TRUE ) { // check for the correct amount of arguments if (wordCount-1 <= 2) { // display all variables if (wordCount == 1) { printVarList(nshHead(varHP)); } // display a variable's specific value else if (wordCount == 2) { arg1 = &userCommand[1][0]; nshFind(nshHead(varHP),arg1); } // set OR reset a variable else { arg1 = &userCommand[1][0]; arg2 = &userCommand[2][0]; strcpy(temp3,userCommand[2]); extendVariable = extendAtFront = extendAtBack = FALSE; // if wanting to extend a variable with the new value on the back if (temp3[0] == '@') { extendAtBack = TRUE; extendVariable = FALSE; // look for the '!' ending variable character for(loopCount=0; loopCount < strlen(temp3); loopCount++) { if (temp3[loopCount] == '!') { extendVariable = TRUE; temp[loopCount-1] = EOS; // get the rest of the string to use to extend variable with loopCount++; int i = 0; for (loopCount; loopCount < strlen(temp3); loopCount++) { temp2[i] = temp3[loopCount]; i++; if (loopCount == (strlen(temp3) -1)) { temp2[i] = EOS; arg2 = temp; arg3 = temp2; break; } } } else if (extendVariable == TRUE) break; else { if (loopCount != 0) temp[loopCount-1] = temp3[loopCount]; } } } // test to see if user wants to extend the variable on the front of it with the new value if (extendAtBack == FALSE) { extendAtFront = FALSE; for(loopCount=0; loopCount < strlen(temp3); loopCount++) { if (temp3[loopCount] == '@' && temp3[loopCount-1] == '!') { int tempSpot, j; j = 0; tempSpot = loopCount + 1; for (tempSpot; tempSpot < strlen(temp3); tempSpot++) { temp[j] = temp3[tempSpot]; j++; } temp[j] = EOS; for (tempSpot = 0; tempSpot < (loopCount-1); tempSpot++) { temp2[tempSpot] = temp3[tempSpot]; } temp2[tempSpot] = EOS; extendAtFront = TRUE; extendVariable = TRUE; arg2 = temp; arg3 = temp2; break; } } } // Set or reset a variable if (extendVariable == FALSE) { // if the head is null if (varHP == NULL){ //varHP = (node*)nshMalloc(sizeof(node)); varHP = (node*) malloc (sizeof(node)); strcpy(varHP->name,&userCommand[1][0]); strcpy(varHP->value, arg2); varHP->next = NULL; } // if need to find its place in the list else { nshInsert(nshHead(varHP), arg1,arg2, VARIABLE); } } else if (extendAtFront == TRUE) { // extendVarValue (node *head, char *set_resetValue, char *getVarValue, char *extendWith, int extendingPosition) didComplete = extendVarValue(nshHead(varHP), arg1, arg2, arg3, varValueInBack); if (didComplete == FALSE) printf("Couldn't extend variable, it doesn't exist\n"); } else { // extendVarValue (node *head, char *set_resetValue, char *getVarValue, char *extendWith, int extendingPosition) didComplete = extendVarValue(nshHead(varHP), arg1, arg2, arg3, varValueInFront); if (didComplete == FALSE) printf("Couldn't extend variable, it doesn't exist\n"); } // reset bool values extendVariable = extendAtFront = extendAtBack = FALSE; } } else { printf("Error - To many arguments for the \"set\" command\n"); continue; } } // if the command is "tes" else if (strcmp(command,"tes") == 0 || (matchAlias(aliasHP, "tes", command))==TRUE ) { // if there are not to many OR to few arguments for this command if (wordCount-1 == 1) { arg1 = &userCommand[1][0]; int status; status = nshRemove(varHP,arg1); if (status == onlyOneNode){ varHP = NULL; } else if (status == popHead){ varHP = (node*) nshNext(varHP); } } else { printf("Error - To many or to few arguments for the \"tes\" command\n"); } } // if the command is "alias" else if (strcmp(command,"alias") == 0 || (matchAlias(aliasHP, "alias", command))==TRUE ) { // if wordCount is 1 - display all aliases (External & Internal) if (wordCount == 1) { printVarList(nshHead(aliasHP)); } // wordCount = 2 - display a specific command alias else if (wordCount == 2) { arg1 = &userCommand[1][0]; nshFind(nshHead(aliasHP),arg1); } // wordCout =3 - set/reset a command alias else { // if the new alias is an internal command arg1 = &userCommand[1][0]; arg2 = &userCommand[2][0]; // if the head is null if (aliasHP == NULL){ //aliasHP = (node*)nshMalloc(sizeof(node)); aliasHP = (node*) malloc(sizeof(node)); strcpy(aliasHP->name,&userCommand[1][0]); strcpy(aliasHP->value, arg2); aliasHP->next = NULL; } // if need to find its place in the list else { nshInsert(nshHead(aliasHP), arg1,arg2, ALIAS); } } } // if the command is "saila" else if (strcmp(command,"saila") == 0 || (matchAlias(aliasHP, "saila", command))==TRUE ) { if (wordCount == 2) { arg1 = &userCommand[1][0]; int status; status = nshRemove(nshHead(aliasHP),arg1); if (status == onlyOneNode){ aliasHP = NULL; } else if (status == popHead){ aliasHP = (node*) nshNext(aliasHP); } } else { printf("To many arguments for 'saila' command\n"); } } // if the command is "exit" else if (strcmp(command,"exit") == 0 || (matchAlias(aliasHP, "exit", command))==TRUE ) { needToExecuteProgram = FALSE; continue; } // if the command is not supported or found else { printf("-bash: %s: external command not supported\n",command); } } } return END_PROGRAM; }
int main( int argc, char *argv[]) { int exit_code= 0; initialize_globals(); if(initialize(argc, argv)) { GtkBuilder *builder; GError *error= NULL; gtk_init (&argc, &argv); builder = gtk_builder_new (); #ifdef STATIC_UI if(!gtk_builder_add_from_string(builder, xlook_glade_data, -1, &error)) { if (error != NULL) { /* Report error to user, and free error */ fprintf (stderr, "Unable to add from string: %s\n", error->message); g_error_free (error); } } #else gtk_builder_add_from_file (builder, "xlook.glade", NULL); #endif // load the rest of them... ui_globals.main_window = (struct GtkWidget *)(gtk_builder_get_object (builder, "mainWindow")); ui_globals.command_history = (struct GtkWidget *)(gtk_builder_get_object (builder, "commandWindow")); // set the font. PangoFontDescription *desc= pango_font_description_from_string("Monospace 9"); char *names[]= { "textview_FileInfo", "textview_Message"}; int ii; for(ii= 0; ii<ARRAY_SIZE(names); ii++) { GtkWidget *w = (struct GtkWidget *)(gtk_builder_get_object (builder, names[ii])); gtk_widget_modify_font(w, desc); } setup_command_window(GTK_WINDOW(ui_globals.command_history)); gtk_builder_connect_signals (builder, NULL); g_object_unref (G_OBJECT (builder)); // set the messages appropriately display_active_window(0); display_active_plot(0); display_active_file(0); gtk_widget_show(GTK_WIDGET(ui_globals.main_window)); // set the font.. // GtkWidget *fileInfo= lookup_widget_by_name(ui_globals.main_window, "textview_FileInfo"); // gtk_widget_modify_font(fileinfo, PangoFontDescription *font_desc); // open if we should from command line. if(strlen(delayed_file_to_open)) { handle_open_filepath(delayed_file_to_open); } gtk_main (); exit_code= 0; } else { exit_code= -1; } return exit_code; }
int main(int argc, char* argv[]) { int x, y; char buffer[255]; FILE* file; int iteration = 0; int progress = -1; int add_headers = 0; double timer; clock_t start; if (argc < 7) { printf("Usage: %s screen_width screen_height wire_width wire_height wire_mili_voltage iteration_limit\n", argv[0]); return 1; } initialize_globals(argv); d("Simulating MPI world"); available_processes = 1; process_number = 0; wire_shift_x = (screen_width - wire_width) / 2; wire_shift_y = (screen_height - wire_height) / 2; process_board_x = sqrt(available_processes); process_board_y = available_processes / process_board_x; process_x = process_number % process_board_x; process_y = process_number / process_board_x; // printf("My rank: %d.\nMy location: %d:%d (board size: %d:%d)\n", process_number, process_x, process_y, process_board_x, process_board_y); if (process_number >= process_board_x * process_board_y) { printf("I'm out of board. Should never happen!\n"); finalize(); return 0; } d("Initiate data storage%s", "."); segment_size_x = screen_width / process_board_x + 2; segment_size_y = screen_height / process_board_y + 2; data = (double*) malloc(sizeof(double) * segment_size_x * segment_size_y); if (0 == process_number) { print_board(); } for (y = 0; y < segment_size_y; ++y) { for (x = 0; x < segment_size_x; ++x) { data[y * segment_size_x + x] = initial_voltage(x, y); } } d("Register custom MPI type (not applicable)%s", "."); start = clock(); communicate(iteration); while (iteration < iteration_limit) { d("Iterations start%s", "."); calculation(iteration); communicate(iteration); ++iteration; if (process_number == 0 && 100 * iteration / iteration_limit > progress) { progress = 100 * iteration / iteration_limit; display_progress(progress, 80); // printf("Progress: %d%% (%d of %d)\n", 5 * progress, iteration, iteration_limit); } } if (0 == process_number) { printf("\n"); } timer = (double) (clock() - start) / CLOCKS_PER_SEC; // Dump data from each process. sprintf(buffer, "data-%dx%d.txt", process_x, process_y); file = fopen(buffer, "w"); for (y = 1; y < segment_size_y - 1; ++y) { for (x = 1; x < segment_size_x - 1; ++x) { fprintf(file, "%f\t%f\t%f\n", 1.0 * (process_x * (segment_size_x - 2) + x) / screen_width, 1.0 * (process_y * (segment_size_y - 2) + y) / screen_height, data[y * segment_size_x + x] ); } fprintf(file, "\n"); } fclose(file); // Log program response. if (process_number == 0) { printf("Board size: %dx%d, iterations limit: %d, used processes: %d, elapsed time: %f\n", screen_width, screen_height, iteration_limit, available_processes, timer); if (file_exists("results.txt") == 0) { add_headers = 1; } file = fopen("results.txt", "a+"); if (add_headers) { fprintf(file, "W\tH\tmax\tproc\tT\n"); } fprintf(file, "%d\t%d\t%d\t%d\t%f\n", screen_width, screen_height, iteration_limit, available_processes, timer); fclose(file); } finalize(); return 0; }
int main( int argc, char* argv[] ) { //test_system_idle_instrumented(); //bwprintf(COM2, "Starting Kernel!"); //bwsetfifo(COM2,OFF); //create the globals structure struct kern_globals GLOBAL; struct request* req; //2385260 //0x2E56C /* bwprintf(COM2, "TID[%d]\tPC[%d]\tPRIOR[%d]\n\n", GLOBAL.ACTIVE_TASK->task_id, GLOBAL.ACTIVE_TASK->pc, GLOBAL.ACTIVE_TASK->priority); bwprintf(COM2, "REQ_NUM[%d]\n", GLOBAL.ACTIVE_TASK->req->req_num); bwprintf(COM2, "SND_TID[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid); bwprintf(COM2, "\tSND_STATE[%d]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].td_state); bwprintf(COM2, "\tSND_PRIOR[%d]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].priority); bwprintf(COM2, "\tSND_PC[%x]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].pc); bwprintf(COM2, "\tSND_REQ_NUM[%d]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req->req_num); bwprintf(COM2, "\t\tSND_REQ_MSG[%x]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->msg); bwprintf(COM2, "\t\tSND_REQ_MSG_LEN[%d]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->msglen); bwprintf(COM2, "\t\tSND_REQ_NUM[%d]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->req_num); bwprintf(COM2, "\t\tSND_REQ_TID_POINTER[%x]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->tid); bwprintf(COM2, "ROUTE_SRV_TID[45]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req->req_num); bwprintf(COM2, "\tROUTE_SRV_STACK_BOTTOM[%x]\n", GLOBAL.USER_TDS[45].stack_space_bottom); bwprintf(COM2, "\tROUTE_SRV_STACK_TOP[%x]\n", GLOBAL.USER_TDS[45].stack_space_top); bwprintf(COM2, "\tROUTE_SRV_STACK_POINTER[%x]\n", GLOBAL.USER_TDS[45].sp); //bwprintf(COM2, "\tROUTE_SRV_ROUTE_STRUCT_SIZE[%x]\n"); bwprintf(COM2, "MSG_POINTER[%x]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msg); bwprintf(COM2, "\tMSG[0] = [%d]\n", ((int*)((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msg)[0]); bwprintf(COM2, "\tMSG[1] = [%d]\n", ((int*)((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msg)[1]); bwprintf(COM2, "\tMSG_LEN[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msglen); bwprintf(COM2, "RPL_POINTER[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->reply); bwprintf(COM2, "\tRPL_LEN[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->replylen); bwgetc(COM2); */ //loop through all of the tds and find the task id with the greatest //number of blocked tasks on it, along with its task id /* int tdindex = 0; int block_max = 0; int i = 0; for(i = 0; i < TID_INDEX_MASK + 1; i++){ int sqs = GLOBAL.USER_TDS[i].send_Q_size; if(sqs > block_max){ block_max = sqs; tdindex = i; } }*/ //bwprintf(COM2, "\n\nBLK[%d] TD_IND[%d] TID[%d] PRIOR[%d]\n\n", block_max, tdindex, GLOBAL.USER_TDS[tdindex].task_id, GLOBAL.USER_TDS[tdindex].priority); //bwgetc(COM2); initialize_globals(&GLOBAL); initialize_first_task(&GLOBAL); initialize_hardware(); while(1){ req = NULL; if(GLOBAL.SCHEDULER.highest_priority == -1){ return 0; } //NO TASKS GLOBAL.ACTIVE_TASK = schedule(&GLOBAL); req = kerexit(GLOBAL.ACTIVE_TASK); //check for quit if(req->req_num == SYSCALL_QUIT){ return 0; } kernel_assert(req != NULL, "req != NULL") handle_request(&GLOBAL, req); } bwprintf(COM2, "GoodBye World\n\n"); cleanup_hardware(); return 0; }
int main() { /* Declare automatic variables. */ size_t cmdlen = 0; char * cmdline = NULL; int retval; /* Display the banner. */ print_banner(); /* Display the usage information if the command line is empty. */ cmdlen = _bgetcmd( NULL, 0 ); if( cmdlen == 0 ) { print_usage(); return( EXIT_FAILURE ); } /* Include space for the terminating null character. */ cmdlen++; /* Get the command line. */ cmdline = malloc( cmdlen ); if( cmdline == NULL ) { return( EXIT_FAILURE ); } cmdlen = _bgetcmd( cmdline, cmdlen ); /* Initialize the globals. */ initialize_globals(); res_initialize_globals(); /* Initialize the statics, which should be globals in gendev. */ cur_file = (file_info *) malloc( sizeof( file_info ) ); cur_file->filebuf = (char * ) malloc( BUF_SIZE ); cur_file->buflen = BUF_SIZE; cur_file->scanptr = NULL; cur_file->usedlen = 0; cur_token = (token *) malloc( sizeof( token ) ); /* Parse the command line: allocates and sets tgt_path. */ retval = parse_cmdline( cmdline ); if( retval == FAILURE ) { free( cmdline ); return( EXIT_FAILURE ); } /* Free the memory held by cmdline and reset it. */ free( cmdline ); cmdline = NULL; /* Check all files in current directory. */ retval = check_directory(); /* Free the memory held by tgt_path and the statics. */ free( tgt_path ); tgt_path = NULL; free( cur_file->filebuf ); cur_file->filebuf = NULL; free( cur_file ); cur_file = NULL; free( cur_token ); cur_token = NULL; /* Print the useage if the process failed. */ if( retval == FAILURE ) { print_usage(); return( EXIT_FAILURE ); } return( EXIT_SUCCESS ); }
int main(const int argc, const char *argv[]) { char buf[BUFFER_MAX]; struct sockaddr addr; socklen_t alen; int lsocket, s, count; pthread_t worker_threads, signal_thread; pthread_attr_t pthread_custom_attr; sigset_t sigs_to_block; pthread_mutex_init(&io_mutex, NULL); pthread_cond_init(&io_wait, NULL); pthread_attr_init(&pthread_custom_attr); sigemptyset(&sigs_to_block); sigaddset(&sigs_to_block, SIGIO); pthread_sigmask(SIG_BLOCK, &sigs_to_block, NULL); pthread_create(&signal_thread, &pthread_custom_attr, io_signal_handler, NULL); ALOGI("installd firing up\n"); if (initialize_globals() < 0) { ALOGE("Could not initialize globals; exiting.\n"); exit(1); } if (initialize_directories() < 0) { ALOGE("Could not create directories; exiting.\n"); exit(1); } drop_privileges(); lsocket = android_get_control_socket(SOCKET_PATH); if (lsocket < 0) { ALOGE("Failed to get socket from environment: %s\n", strerror(errno)); exit(1); } if (listen(lsocket, 5)) { ALOGE("Listen on socket failed: %s\n", strerror(errno)); exit(1); } fcntl(lsocket, F_SETFD, FD_CLOEXEC); for (;;) { alen = sizeof(addr); s = accept(lsocket, &addr, &alen); if (s < 0) { ALOGE("Accept failed: %s\n", strerror(errno)); continue; } fcntl(s, F_SETFD, FD_CLOEXEC); fcntl(s, F_SETFL, O_ASYNC | O_NONBLOCK); fcntl(s, F_SETSIG, 0); fcntl(s, F_SETOWN, getpid()); write_error = 0; ALOGI("new connection\n"); for (;;) { unsigned short count; int id; if (readx(s, &id, sizeof(id))) { ALOGE("failed to read transaction id\n"); break; } if (readx(s, &count, sizeof(count))) { ALOGE("failed to read size\n"); break; } if ((count < 1) || (count >= BUFFER_MAX)) { ALOGE("invalid size %d\n", count); break; } if (readx(s, buf, count)) { ALOGE("failed to read command\n"); break; } buf[count] = 0; thread_parm *args = (thread_parm*) malloc(sizeof(thread_parm)); args->s = s; strncpy(args->cmd, buf, count + 1); args->id = id; pthread_create(&worker_threads, &pthread_custom_attr, executeAsync, (void*) args); } ALOGI("closing connection\n"); close(s); } pthread_kill(&signal_thread, SIGKILL); pthread_join(&signal_thread, NULL); return 0; }
int main (int argc, char* argv[]) { char filename1[200]; char filename2[200]; char pairs_file[200]; char fileout[200]; FILE* query_fp = 0; FILE* reference_fp = 0; FILE* fp_pairs = 0; FILE* fpout = stdout; int total_pairs = 0; pair_struct* pairs = 0; /* Set Default Parameter Values*/ length_5p_for_weighting = 8; /* The 5' sequence length to be weighed except for the last residue*/ scale = 4.0; /* The 5' miRNA scaling parameter*/ strict = 0; /* Strict seed model on/off*/ debug = 0; /* Debugging mode on/off*/ key_value_pairs = 0; gap_open = -9.0; /* Gap-open Penalty*/ gap_extend = -4.0; /* Gap-extend Penalty*/ score_threshold = 140.0; /* SW Score Threshold for reporting hits*/ energy_threshold = 1.0; /* Energy Threshold (DG) for reporting hits*/ verbosity = 1; /* Verbose mode on/off*/ outfile = 0; /* Dump to file on/off*/ truncated = 0; /* Truncate sequences on/off*/ no_energy = 0; /* Turn off Vienna Energy Calcs - FASTER*/ restricted = 0; /* Perform restricted search space*/ parse_command_line(argc, argv, filename1, filename2, fileout, pairs_file); if (gap_open > 0.0 || gap_extend > 0.0) { fprintf(stderr, "Error: gap penalties may not be greater than 0\n"); return 1; } if (truncated < 0) { fprintf(stderr, "Error: negative value give for UTR truncation\n"); return 1; } if ((query_fp = fopen(filename1, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename1); return 1; } if ((reference_fp = fopen(filename2, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename2); return 1; } fclose(reference_fp); if ((outfile) && ((fpout = fopen(fileout, "w")) == NULL)) { fprintf(stderr, "Error: Cannot create output file %s\n", fileout); return 1; } if (restricted) { if ((fp_pairs = fopen(pairs_file, "r")) == NULL) { fprintf(stderr, "Error: Cannot open restrict pairs file %s\n", pairs_file); return 1; } /* Initialize the pairs list for restriced searches*/ total_pairs = load_pairs(fp_pairs, &pairs); fclose(fp_pairs); } initialize_globals(); print_parameters(filename1, filename2, fpout); if (restricted && verbosity) { printf("Performing Restricted Scan on:%d pairs\n", total_pairs); } find_targets(query_fp, fpout, pairs, total_pairs, filename2); destroy_globals(); if (outfile) fclose(fpout); fclose(query_fp); return 0; }