int main(int argc, char **argv) { int i; char *git_path; char *tmp; unsigned int gti_speed; draw_fn_t draw_fn; tmp = getenv("GTI_SPEED"); if (!tmp || sscanf(tmp, "%u", >i_speed) != 1) { gti_speed = GTI_SPEED; } open_term(); TERM_WIDTH = term_width(); FRAME_TIME = 1000 * 1000 * 10 / (gti_speed + TERM_WIDTH + 1); draw_fn = select_command(argc, argv); init_space(); for (i = -20; i < TERM_WIDTH; i++) { draw_fn(i); clear_car(i); } move_to_top(); fflush(TERM_FH); git_path = getenv("GIT"); if (git_path) { execv(git_path, argv); } else { execvp(GIT_NAME, argv); } /* error in exec if we land here */ perror(GIT_NAME); return 1; }
int main(int argc, char **argv) { int i; char *git_path; (void) argc; open_term(); TERM_WIDTH = term_width(); SLEEP_DELAY = 1000000 / (TERM_WIDTH + GTI_SPEED); init_space(); for (i = -20; i < TERM_WIDTH; i++) { draw_car(i); usleep(SLEEP_DELAY); clear_car(i); } move_to_top(); fflush(TERM_FH); git_path = getenv("GIT"); if (git_path) { execv(git_path, argv); } else { execvp(GIT_NAME, argv); } /* error in exec if we land here */ perror(GIT_NAME); return 1; }
void disk_arm::sstf(){ int shortest; int direction = seek_direction; int current = current_cylinder; init_space("SSTF"); printf("%d", current); for (int i = 0; i < request_number; i ++){ int distance = 0x3f3f3f3f; for (int j = 0; j < request_number; j ++){ if (cylinder[j] == -1) continue; if (distance > abs(current - cylinder[j])){ distance = abs(current - cylinder[j]); shortest = j; } } if (need_chang(current, cylinder[shortest], direction)){ seek_chang ++; direction = !direction; printf("\n%d->%d", current, cylinder[shortest]); }else printf("->%d", cylinder[shortest]); seek_number += abs(current - cylinder[shortest]); current = cylinder[shortest]; cylinder[shortest] = -1; } report(); }
void disk_arm::scan(){ int direction = seek_direction; int current = current_cylinder; init_space("SCAN"); printf("%d", current); int min = 0, max = 199; for (int i = 0; i < request_number; i ++){ int distance = 0x3f3f3f3f; int shortest = -1; for (int j = 0; j < request_number; j ++){ if (cylinder[j] == -1 || need_chang(current, cylinder[j], direction)) continue; if (distance > abs(current - cylinder[j])){ distance = abs(current - cylinder[j]); shortest = j; } } if (shortest == -1){ i --; int tmp = current; current = direction?max:min; seek_number += abs(tmp - current); direction = !direction; printf("->%d\n%d", current, current); continue; } printf("->%d", cylinder[shortest]); seek_number += abs(current - cylinder[shortest]); current = cylinder[shortest]; cylinder[shortest] = -1; } report(); }
int main(int argc, char **argv) { (void) argc; int i; TERM_WIDTH = term_width(); SLEEP_DELAY = 1000000 / GTI_SPEED; init_space(); for (i = -20; i < TERM_WIDTH; i++) { draw_car(i); usleep(SLEEP_DELAY); clear_car(i); } return 1; }
int main(int argc, char **argv) { (void) argc; int i; TERM_WIDTH = term_width(); init_space(); for (i = -20; i < TERM_WIDTH; i++) { draw_car(i); usleep(20*1000); clear_car(i); } execvp(GIT_NAME, argv); /* error in exec if we land here */ perror(GIT_NAME); return 1; }
void disk_arm::fcfs(){ int current = current_cylinder; int direction = seek_direction; init_space("FCFS"); printf("%d", current); for (int i = 0; i < request_number; i ++){ if (need_chang(current, cylinder[i], direction)){ seek_chang ++; direction = !direction; printf("\n%d->%d", current, cylinder[i]); }else printf("->%d", cylinder[i]); seek_number += abs(current - cylinder[i]); current = cylinder[i]; } puts(""); report(); }
oldSpace::oldSpace(const char *nm, int32 &size, caddr_t desiredAddress) : space(nm, size) { next_space= NULL; size++; // +1 for the invariant // size rounded up for us in OS::allocate_idealized_page_aligned char *mem= OS::allocate_idealized_page_aligned(size, nm, desiredAddress, false); if (!mem) { size= 0; return; } if (OS::is_directed_allocation_supported() && mem != desiredAddress) { // must have fallen back on malloc() size= 0; delete [] mem; return; } int32 old_size = size; // init_space rounds it up! init_space(nm, size, mem); if (size != old_size) fatal("size changed"); }
int main(int argc, char **argv) { (void) argc; int i; TERM_WIDTH = term_width(); SLEEP_DELAY = 2000000 / (TERM_WIDTH + GT_SPEED); init_space(); for (i = TERM_WIDTH; i > -81; i--) { draw_car(i); usleep(SLEEP_DELAY); clear_car(i); } char *git_path = getenv("GIT"); if (git_path) { execv(git_path, argv); } else { execvp(GIT_NAME, argv); } /* error in exec if we land here */ perror(GIT_NAME); return 1; }