void *g_malloc_with_owner(unsigned long int memory, const char *description, int for_task, int use_ems, int owner) { #ifdef DEBUG char s[80]; #endif int not_lock_dos; void *memory_pointer; if (tasking) { not_lock_dos = !islocked(DOS_SEM); if (not_lock_dos) lock_dos(433); } memory_pointer = allocate_some_memory(memory,description,owner,for_task); #ifdef DEBUG sprintf(s,"Mallocing memory pointer %p",memory_pointer); #endif if (tasking) { if (not_lock_dos) unlock_dos(); } return (memory_pointer); }
int g_free(void *memory_pointer) { #ifdef DEBUG char s[80]; #endif int dos_not_locked; int result; int now_tasking = tasking; if (now_tasking) { dos_not_locked = !islocked(DOS_SEM); if (dos_not_locked) lock_dos(435); } result=!free_some_memory(memory_pointer); #ifdef DEBUG sprintf(s,"Freeing pointer %p",memory_pointer); #endif if (now_tasking) { if (dos_not_locked) unlock_dos(); } return (result); };
int g_free_from_who(void *memory_pointer, int who) { #ifdef DEBUG char s[80]; #endif int not_lock_dos; int result; int now_tasking = tasking; if (now_tasking) { not_lock_dos = !islocked(DOS_SEM); if (not_lock_dos) lock_dos(434); } result=!free_some_memory(memory_pointer); #ifdef DEBUG sprintf(s,"Freeing pointer %p",memory_pointer); #endif if (now_tasking) { if (not_lock_dos) unlock_dos(); } return (result); };
void g_free_all_handles(int task_id) /* Should only be called in tasker */ { mem_entry *cur_entry = &mem_array[mem_handles]; file_entry *cur_file_entry = &file_array[file_handles]; int not_lock_dos = !islocked(DOS_SEM); int current = mem_handles; if (not_lock_dos) lock_dos(440); while (current > 0) { cur_entry--; current--; if ((cur_entry->task_id == task_id) && (!cur_entry->kept_open) && (!(cur_entry->empty))) { free_some_memory(cur_entry->memory_pointer); }; }; current=file_handles; while (current > 0) { current--; cur_file_entry--; if ((cur_file_entry->task_id == task_id) && (!cur_file_entry->kept_open)) { fclose(cur_file_entry->file_pointer); delete_file_entry(current); }; }; if (not_lock_dos) unlock_dos(); };
void *g_malloc(unsigned long int memory, const char *description) { #ifdef DEBUG char s[80]; #endif int not_lock_dos; void *memory_pointer; if (tasking) { not_lock_dos = !islocked(DOS_SEM); if (not_lock_dos) lock_dos(432); } memory_pointer = allocate_some_memory(memory,description,1,tswitch); #ifdef DEBUG if (tasking) { sprintf(s,"Mallocing memory pointer %p",memory_pointer); print_str_cr_to(s,0); } #endif if (tasking) { if (not_lock_dos) unlock_dos(); } return (memory_pointer); };
void VEObj::unlock() { if (!islocked()) return; vzctl2_env_unlock_prvt(ctid(), lock_fd, priv); lock_fd = -1; }
void proto_write_buffer(FILE *fileptr, char *buffer, int length) { int flag = islocked(DOS_SEM); if (!flag) lock_dos(372); fwrite(buffer, 1, length, fileptr); if (!flag) unlock_dos(); };
int g_owns_file(void *file_pointer) { int not_lock_dos = !islocked(DOS_SEM); int file_point; if (not_lock_dos) lock_dos(446); file_point = find_file_pointer(file_pointer); if (not_lock_dos) unlock_dos(); return (file_point); };
long int proto_file_length(FILE *fileptr) { int flag = islocked(DOS_SEM); long int temp; if (!flag) lock_dos(373); fseek(fileptr, 0, SEEK_END); temp = ftell(fileptr); fseek(fileptr, 0, SEEK_SET); if (!flag) unlock_dos(); return (temp); }
void proto_read_buffer(FILE *fileptr, char *buffer, int length, int *readlength) { char *clearbuffer; char *endbuffer = buffer + length; int flag = islocked(DOS_SEM); if (!flag) lock_dos(371); *readlength = fread(buffer, 1, length, fileptr); if (!flag) unlock_dos(); clearbuffer = buffer + *readlength; while (clearbuffer < endbuffer) *clearbuffer++ = EOF_CHR; };
void *g_calloc(size_t num, size_t size, const char *description) { int not_lock_dos = !islocked(DOS_SEM); void *memory_pointer; if (not_lock_dos) lock_dos(439); memory_pointer = calloc(num,size); if (memory_pointer) add_memory_entry(memory_pointer,tswitch,(num*size),0,description); if (not_lock_dos) unlock_dos(); return (memory_pointer); };
int load_bbs_user(char *directory, int number, struct bbs_user_account *bbs_ptr) { int flag=islocked(DOS_SEM); int number_users; FILE *fileptr; char bbs_user_file[40]; create_blank_bbs_acct(bbs_ptr); sprintf(bbs_user_file,"%s\\DEFAULTS",directory); if (!flag) lock_dos(); if (!(fileptr=g_fopen(bbs_user_file,"rb","BBS#6"))) { log_error("*bbs file wouldn't open"); log_error(bbs_user_file); if (!flag) unlock_dos(); return 1; } fseek(fileptr,0,SEEK_SET); fscanf(fileptr,"%d\n",&number_users); if (number>number_users) { log_error("*LOAD BBS ACCT : system tried to read past end of user file"); g_fclose(fileptr); if (!flag) unlock_dos(); return 1; } else fseek(fileptr, (long int)sizeof(struct bbs_user_account)*(number+1),SEEK_SET); if (!fread(bbs_ptr, sizeof(struct bbs_user_account), 1, fileptr)) { log_error("* fread() failed on file "); log_error(bbs_user_file); g_fclose(fileptr); if (!flag) unlock_dos(); return 1; } if (g_fclose(fileptr)) { log_error("fclose failed"); log_error(bbs_user_file); if (!flag) unlock_dos(); return 1; } if (!flag) unlock_dos(); return 0; }
int g_flush(FILE *file_pointer) { int not_lock_dos = !islocked(DOS_SEM); int file_point; int result=0; if (not_lock_dos) lock_dos(445); file_point = find_file_pointer(file_pointer); if (file_point != -1) { result=fflush(file_pointer); }; if (not_lock_dos) unlock_dos(); return (result); };
int32_t HAL_Sharedmemory::lock() { sem_wait(context->semaphore); //open semaphore //read lockflag if (islocked()) { sem_post(context->semaphore); //close semaphore return false; } else { context->header->lockFlag = 1; context->iLockedIt = 1; sem_post(context->semaphore); //close semaphore return true; } }
int g_fclose(FILE *file_pointer) { int not_lock_dos = !islocked(DOS_SEM); int file_point; int result=0; if (not_lock_dos) lock_dos(443); file_point = find_file_pointer(file_pointer); if (file_point != -1) { result=fclose(file_pointer); delete_file_entry(file_point); }; if (not_lock_dos) unlock_dos(); return (result); };
int load_class(int class_number, struct user_data *class_ptr) { int flag=!islocked(DOS_SEM); int number_classes; FILE *fileptr; if (flag) lock_dos(71); if (!(fileptr=g_fopen(userfile,"rb","CLASS#1"))) { log_error("*class file wouldn't open"); log_error(classfile); if (flag) unlock_dos(); return 1; } fseek(fileptr,0,SEEK_SET); fscanf(fileptr,"%d\n",&number_classes); if (class_number>number_classes) { log_error("*LOAD CLASS : system tried to read past end of class file"); g_fclose(fileptr); if (flag) unlock_dos(); return 1; } else fseek(fileptr, (long int)sizeof(struct user_data)*(class_number+NUMDEFAULT),SEEK_SET); if (!fread(class_ptr, sizeof(struct user_data), 1, fileptr)) { log_error("* fread() failed on file "); log_error(classfile); g_fclose(fileptr); if (flag) unlock_dos(); return 1; } if (g_fclose(fileptr)) { log_error("g_fclose failed"); log_error(classfile); if (flag) unlock_dos(); return 1; } if (flag) unlock_dos(); return 0; }
int g_owns_memory(void *memory_pointer) { int not_lock_dos; int mem_point; if (tasking) { not_lock_dos = !islocked(DOS_SEM); if (not_lock_dos) lock_dos(441); } mem_point = find_memory_pointer(memory_pointer); if (tasking) { if (not_lock_dos) unlock_dos(); } return (mem_point); };
int g_ftransfer(FILE *file_pointer, int new_task_id) { int not_lock_dos = !islocked(DOS_SEM); int file_point; int response = 0; if (not_lock_dos) lock_dos(444); file_point = find_file_pointer(file_pointer); if (file_point != -1) if (file_array[file_point].task_id == tswitch) { file_array[file_point].task_id = new_task_id; response = 1; }; if (not_lock_dos) unlock_dos(); return (response); };
void *g_realloc(void *memory_pointer,size_t new_size) { int not_lock_dos = !islocked(DOS_SEM); void *new_pointer; int mem_point; if (not_lock_dos) lock_dos(438); mem_point = find_memory_pointer(memory_pointer); if (mem_point == -1) { if (not_lock_dos) unlock_dos(); return NULL; }; new_pointer = realloc(memory_pointer,new_size); if (new_pointer) { mem_array[mem_point].size = new_size; mem_array[mem_point].memory_pointer = new_pointer; }; if (not_lock_dos) unlock_dos(); return (new_pointer); };
int add_task_to_scheduler(task_type task, void *task_data, int task_call, unsigned long int task_time, int active, unsigned int stack_size, char *description) { int temp_num = num_schedule; int flag; int lockflag= !islocked(DOS_SEM); int count; struct schedule_task *curtask = &schedule[num_schedule]; lock(SCHEDULE_SEM); if (num_schedule == (MAX_SCHEDULED-1)) { unlock(SCHEDULE_SEM); return (-1); }; curtask->int_type = task_call; curtask->task_time = task_time; curtask->call_function = task; curtask->task_data = task_data; curtask->active = active; curtask->stack_size = stack_size; strncpy(curtask->task_name,description,SCHEDULE_DESC_LENGTH-1); curtask->task_name[SCHEDULE_DESC_LENGTH-1] = 0; do { next_id++; flag = 0; for (count=0;count<num_schedule;count++) if (schedule[count].id == next_id) flag = 1; } while (flag); curtask->id = next_id; if (lockflag) lock_dos(207); curtask->last_event = time(NULL); if (lockflag) unlock_dos(); num_schedule++; calc_next_event(temp_num); unlock(SCHEDULE_SEM); set_next_scheduled_event(); return (next_id); };
RETSIGTYPE sigerr(int sig) { signal(sig,SIG_DFL); aso_done(); write_log("got SIG%s signal",sigs[sig]); if(cfgs(CFG_PIDFILE))if(getpid()==islocked(ccs))lunlink(ccs); IFPerl(perl_done(1)); log_done(); tty_close(); qqreset();sline("");title(""); cls_close(ssock); cls_shutd(lins_sock); cls_shutd(uis_sock); switch(sig) { case SIGSEGV: case SIGFPE: case SIGBUS: case SIGABRT: abort(); default: exit(1); } }
int g_transfer(void *memory_pointer,int new_task_id) { int not_lock_dos; int mem_point; int response = 0; if (tasking) { not_lock_dos = !islocked(DOS_SEM); if (not_lock_dos) lock_dos(436); } mem_point = find_memory_pointer(memory_pointer); if (mem_point != -1) { mem_array[mem_point].task_id = new_task_id; response = 1; }; if (tasking) { if (not_lock_dos) unlock_dos(); } return (response); };
int g_keep_memory(void *memory_pointer,int keep_it) { int not_lock_dos; int mem_point; int response = 0; if (tasking) { not_lock_dos = !islocked(DOS_SEM); if (not_lock_dos) lock_dos(437); } mem_point = find_memory_pointer(memory_pointer); if (mem_point != -1) { mem_array[mem_point].kept_open = keep_it; response = 1; }; if (tasking) { if (not_lock_dos) unlock_dos(); } return (response); };
int save_bbs_user(char *directory, int number, struct bbs_user_account *bbs_ptr) { int flag=islocked(DOS_SEM); int number_users; int putit; struct bbs_user_account temp; FILE *fileptr; char bbs_user_file[40]; sprintf(bbs_user_file,"%s\\DEFAULTS",directory); if (!flag) lock_dos(); if (!(fileptr=g_fopen(bbs_user_file,"rb+","BBS#7"))) { if (!(fileptr=g_fopen(bbs_user_file,"wb","BBS#8"))) { log_error(bbs_user_file); if (!flag) unlock_dos(); return 1; }; fseek(fileptr,0,SEEK_SET); fprintf(fileptr,"0\n"); } fseek(fileptr,0,SEEK_SET); fscanf(fileptr,"%d\n",&number_users); if (number>=number_users) { log_error("* SYSTEM tried to add user that exhisted"); create_blank_bbs_acct(&temp); fseek(fileptr, (long int)sizeof(struct bbs_user_account)* (number_users),SEEK_SET); for (putit=number_users;putit<number;putit++) if (!fwrite(&temp, sizeof(struct bbs_user_account), 1, fileptr)) { log_error(bbs_user_file); g_fclose(fileptr); if (!flag) unlock_dos(); return 1; } fseek(fileptr,0,SEEK_SET); fprintf(fileptr,"%d\n",number+1); } fseek(fileptr, (long int)sizeof(struct bbs_user_account)*(number+1),SEEK_SET); if (!fwrite(bbs_ptr, sizeof(struct bbs_user_account), 1, fileptr)) { log_error(bbs_user_file); log_error("*tried to write user and failed"); g_fclose(fileptr); if (!flag) unlock_dos(); return 1; } fflush(fileptr); if (g_fclose(fileptr)) { log_error(bbs_user_file); if (!flag) unlock_dos(); return 1; } if (!flag) unlock_dos(); return 0; };
void gFBDC::exec(const gOpcode *o) { switch (o->opcode) { case gOpcode::setPalette: { gDC::exec(o); setPalette(); break; } case gOpcode::flip: { if (surface_back.data_phys) { gUnmanagedSurface s(surface); surface = surface_back; surface_back = s; if (surface.data_phys > surface_back.data_phys) fb->setOffset(surface_back.y); else fb->setOffset(0); } break; } case gOpcode::waitVSync: { static timeval l; static int t; timeval now; if (t == 1000) { gettimeofday(&now, 0); int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000; eDebug("[gFBDC] %d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1)); l = now; t = 0; } ++t; fb->blit(); fb->waitVSync(); break; } case gOpcode::flush: fb->blit(); #if defined(CONFIG_HISILICON_FB) if(islocked()==0) { bcm_accel_blit( surface.data_phys, surface.x, surface.y, surface.stride, 0, surface_back.data_phys, surface_back.x, surface_back.y, surface_back.stride, 0, 0, surface.x, surface.y, 0, 0, surface.x, surface.y, 0, 0); } #endif break; #ifdef HAVE_OSDANIMATION case gOpcode::sendShow: CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x01); break; case gOpcode::sendHide: CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x10); break; #endif default: gDC::exec(o); break; } }
void gFBDC::exec(const gOpcode *o) { switch (o->opcode) { case gOpcode::setPalette: { gDC::exec(o); setPalette(); break; } case gOpcode::flip: { if (surface_back.data_phys) { gUnmanagedSurface s(surface); surface = surface_back; surface_back = s; if (surface.data_phys > surface_back.data_phys) fb->setOffset(surface_back.y); else fb->setOffset(0); } break; } case gOpcode::waitVSync: { static timeval l; static int t; timeval now; if (t == 1000) { gettimeofday(&now, 0); int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000; eDebug("[gFBDC] %d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1)); l = now; t = 0; } ++t; fb->blit(); fb->waitVSync(); break; } case gOpcode::flush: #ifdef USE_LIBVUGLES2 if (gles_is_animation()) gles_do_animation(); else fb->blit(); #else fb->blit(); #endif #if defined(CONFIG_HISILICON_FB) if(islocked()==0) { bcm_accel_blit( surface.data_phys, surface.x, surface.y, surface.stride, 0, surface_back.data_phys, surface_back.x, surface_back.y, surface_back.stride, 0, 0, surface.x, surface.y, 0, 0, surface.x, surface.y, 0, 0); } #endif #ifdef HAVE_HISILICON_ACCEL dinibot_accel_notify(); #endif break; case gOpcode::sendShow: { #ifdef HAVE_OSDANIMATION CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x01); #endif #ifdef USE_LIBVUGLES2 gles_set_buffer((unsigned int *)surface.data); gles_set_animation(1, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height()); #endif break; } case gOpcode::sendHide: { #ifdef HAVE_OSDANIMATION CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x10); #endif #ifdef USE_LIBVUGLES2 gles_set_buffer((unsigned int *)surface.data); gles_set_animation(0, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height()); #endif break; } #ifdef USE_LIBVUGLES2 case gOpcode::setView: { gles_viewport(o->parm.setViewInfo->size.width(), o->parm.setViewInfo->size.height(), fb->Stride()); break; } #endif default: gDC::exec(o); break; } }
void gFBDC::setResolution(int xres, int yres, int bpp) { if (m_pixmap && (surface.x == xres) && (surface.y == yres) && (surface.bpp == bpp) #if defined(CONFIG_HISILICON_FB) && islocked()==0 #endif ) return; if (gAccel::getInstance()) gAccel::getInstance()->releaseAccelMemorySpace(); fb->SetMode(xres, yres, bpp); surface.x = xres; surface.y = yres; surface.bpp = bpp; surface.bypp = bpp / 8; surface.stride = fb->Stride(); surface.data = fb->lfb; for (int y=0; y<yres; y++) // make whole screen transparent memset(fb->lfb+ y * xres * 4, 0x00, xres * 4); surface.data_phys = fb->getPhysAddr(); int fb_size = surface.stride * surface.y; if (fb->getNumPages() > 1) { surface_back = surface; surface_back.data = fb->lfb + fb_size; surface_back.data_phys = surface.data_phys + fb_size; fb_size *= 2; } else { surface_back.data = 0; surface_back.data_phys = 0; } eDebug("[gFBDC] resolution: %dx%dx%d stride=%d, %dkB available for acceleration surfaces.", surface.x, surface.y, surface.bpp, fb->Stride(), (fb->Available() - fb_size)/1024); if (gAccel::getInstance()) gAccel::getInstance()->setAccelMemorySpace(fb->lfb + fb_size, surface.data_phys + fb_size, fb->Available() - fb_size); #ifdef HAVE_HISILICON_ACCEL dinobot_accel_register(&surface,&surface_back); #endif if (!surface.clut.data) { surface.clut.colors = 256; surface.clut.data = new gRGB[surface.clut.colors]; memset(static_cast<void*>(surface.clut.data), 0, sizeof(*surface.clut.data)*surface.clut.colors); } surface_back.clut = surface.clut; #if defined(CONFIG_HISILICON_FB) if(islocked()==0) { gUnmanagedSurface s(surface); surface = surface_back; surface_back = s; } #endif m_pixmap = new gPixmap(&surface); }
int main(int argc, char *argv[]) { int i, fd; off_t off, loff; ssize_t rd; int didsth = 0; #ifdef USE_INOTIFY int ifd, wd; #endif close(0); if (argc < 2) { /* little better than glob(3)... */ execl("/bin/sh", "sh", "-c", "fq ${NQDIR:+$NQDIR/},*", (char *) 0); exit(111); } #ifdef USE_INOTIFY ifd = inotify_init(); if (ifd < 0) exit(111); #endif for (i = 1; i < argc; i++) { loff = 0; fd = open(argv[i], O_RDONLY); if (fd < 0) continue; /* skip not running jobs, unless we did not output anything yet * and are at the last argument. */ if (!islocked(fd) && (didsth || i != argc - 1)) continue; write(1, "==> ", 4); write(1, argv[i], strlen(argv[i])); write(1, "\n", 1); didsth = 1; #ifdef USE_INOTIFY wd = inotify_add_watch(ifd, argv[i], IN_MODIFY|IN_CLOSE_WRITE); #endif while (1) { off = lseek(fd, 0, SEEK_END); if (off < loff) loff = off; /* file truncated */ if (off == loff) { if (flock(fd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) { #ifdef USE_INOTIFY /* any inotify event is good */ read(ifd, ibuf, sizeof ibuf); #else /* poll for size change */ while (off == lseek(fd, 0, SEEK_END)) usleep(DELAY); #endif continue; } else { flock(fd, LOCK_UN); break; } } if (off - loff > sizeof buf) off = loff + sizeof buf; rd = pread(fd, &buf, off - loff, loff); write(1, buf, rd); loff += rd; } #ifdef USE_INOTIFY inotify_rm_watch(ifd, wd); #endif close(fd); } #ifdef USE_INOTIFY close(ifd); #endif return 0; }
void calc_next_event(int which_calc) { time_t new_time; struct tm dep_time; struct tm last_event; int lockflag=!islocked(DOS_SEM); struct tm *temp_time; unsigned long int task_time; unsigned long int ln_event; int adj_secs=0; switch (schedule[which_calc].int_type) { case ONE_SHOT_TASK: schedule[which_calc].next_event = schedule[which_calc].task_time; break; case DAILY_TASK: if (lockflag) lock_dos(201); temp_time = localtime(&schedule[which_calc].last_event); last_event = *temp_time; ln_event = ((unsigned long int)schedule[which_calc].last_event) + (SECS_IN_DAY); temp_time = localtime(&ln_event); if ((last_event.tm_isdst) && (!temp_time->tm_isdst)) { //print_str_cr_to("--> Going to Daylight savings time",0); adj_secs = (3600); } if ((!last_event.tm_isdst) && (temp_time->tm_isdst)) { //print_str_cr_to("--> Going to NON-daylight savings time",0); adj_secs = - 3600; } ln_event+=adj_secs; temp_time = localtime(&ln_event); dep_time = *temp_time; if (lockflag) unlock_dos(); task_time = schedule[which_calc].task_time; dep_time.tm_hour = (unsigned int) (unsigned long int)(task_time / 3600); dep_time.tm_min = (unsigned int) (unsigned long int) (((task_time) % 3600)/60); dep_time.tm_sec = (unsigned int) (unsigned long int)((task_time) % 60); if (lockflag) lock_dos(202); new_time = mktime(&dep_time); if (lockflag) unlock_dos(); /* if (new_time<=schedule[which_calc].last_event) new_time += SECS_IN_DAY; */ schedule[which_calc].next_event = new_time; break; case PERIODIC_TASK: schedule[which_calc].next_event = (time_t) ((unsigned long int)(schedule[which_calc].last_event) + schedule[which_calc].task_time); break; case REL_SHOT_TASK: schedule[which_calc].next_event = (time_t) ((unsigned long int)(schedule[which_calc].last_event) + schedule[which_calc].task_time); schedule[which_calc].int_type = ONE_SHOT_TASK; break; case HOURLY_TASK: ln_event = (3600l - (schedule[which_calc].last_event % 3600l)); schedule[which_calc].next_event = schedule[which_calc].last_event + ln_event; break; case REL_NOW_TASK: if (lockflag) lock_dos(205); time(&new_time); if (lockflag) unlock_dos(); schedule[which_calc].last_event = new_time; schedule[which_calc].next_event = (time_t) ((unsigned long int)(schedule[which_calc].last_event) + schedule[which_calc].task_time); schedule[which_calc].int_type = ONE_SHOT_TASK; break; }; };
time_t see_if_scheduled_event_occurs(void) { time_t now; int which_ev; int count; int lockflag=!islocked(DOS_SEM); int flag; int made_task=-1; task_type which_task; void *task_data; unsigned int stack_size; char task_name[SCHEDULE_DESC_LENGTH+1]; if (lockflag) lock_dos(206); time(&now); if (lockflag) unlock_dos(); if (which_next_event_id == -1) { set_next_scheduled_event(); return (now); }; if (now < next_scheduled_event) return (now); lock(SCHEDULE_SEM); which_ev = find_schedule_with_id(which_next_event_id); if (which_ev == -1) return (now); which_task = schedule[which_ev].call_function; task_data = schedule[which_ev].task_data; stack_size = schedule[which_ev].stack_size; strcpy(task_name,schedule[which_ev].task_name); if ((schedule[which_ev].int_type) == ONE_SHOT_TASK) { unlock(SCHEDULE_SEM); del_task_from_scheduler(which_next_event_id); } else { schedule[which_ev].last_event = now; calc_next_event(which_ev); unlock(SCHEDULE_SEM); }; set_next_scheduled_event(); count=MAX_THREADS-1; flag=1; while (made_task<0) { while ((count>=0) && flag) if (!get_task_status(count)) flag=0; else count--; schedule_data[count] = task_data; if (!flag) #ifdef DEBUG_COMPILE_SCH made_task = 3; #else made_task = make_task(which_task,stack_size,count,6,task_name); #endif DosSleep(3); } return (now); };