void ErrorHandler::ReadErrorMsg(const char *ArcName,const char *FileName) { #ifndef SILENT ErrMsg(ArcName,St(MErrRead),FileName); SysErrMsg(); #endif }
void ErrorHandler::GeneralErrMsg(const char *Msg) { #ifndef SILENT Log(NULL,"%s",Msg); SysErrMsg(); #endif }
void ErrorHandler::WriteErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW) { #ifndef SILENT ErrMsg(ArcName,St(MErrWrite),FileName); SysErrMsg(); #endif }
void ErrorHandler::WriteErrorMsg(string sParfileName, const char *ArcName,const char *FileName) { #ifndef SILENT ErrMsg(sParfileName, ArcName,St(MErrWrite),FileName); SysErrMsg(sParfileName); #endif }
void ErrorHandler::WriteErrorFAT(const wchar *FileName) { SysErrMsg(); uiMsg(UIERROR_NTFSREQUIRED,FileName); #if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL) Exit(RARX_WRITE); #endif }
void ErrorHandler::OpenErrorMsg(const char *ArcName,const char *FileName) { #ifndef SILENT Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotOpen),FileName); Alarm(); SysErrMsg(); #endif }
void ErrorHandler::OpenErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW) { #ifndef SILENT if (FileName!=NULL) Log(ArcName,St(MCannotOpen),FileName); Alarm(); SysErrMsg(); #endif }
void ErrorHandler::WriteErrorFAT(const char *FileName,const wchar *FileNameW) { #if !defined(SILENT) && !defined(SFX_MODULE) SysErrMsg(); ErrMsg(NULL,St(MNTFSRequired),FileName); #endif #if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL) Throw(RARX_WRITE); #endif }
void ErrorHandler::GeneralErrMsg(const wchar *fmt,...) { va_list arglist; va_start(arglist,fmt); wchar Msg[1024]; vswprintf(Msg,ASIZE(Msg),fmt,arglist); uiMsg(UIERROR_GENERALERRMSG,Msg); SysErrMsg(); va_end(arglist); }
void ErrorHandler::WriteErrorFAT(string sParfileName, const char *FileName) { #if !defined(SILENT) && !defined(SFX_MODULE) SysErrMsg(sParfileName); ErrMsg(sParfileName, NULL,St(MNTFSRequired),FileName); #endif #if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL) Throw(WRITE_ERROR); #endif }
void ErrorHandler::CloseError(const wchar *FileName) { if (!UserBreak) { uiMsg(UIERROR_FILECLOSE,FileName); SysErrMsg(); } #if !defined(SILENT) || defined(RARDLL) Exit(RARX_FATAL); #endif }
bool ErrorHandler::AskRepeatRead(const char *FileName,const wchar *FileNameW) { #if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE) if (!Silent) { SysErrMsg(); mprintf("\n"); Log(NULL,St(MErrRead),FileName); return(Ask(St(MRetryAbort))==1); } #endif return(false); }
void ErrorHandler::CloseError(string sParfileName, const char *FileName) { #ifndef SILENT if (!UserBreak) { ErrMsg(sParfileName, NULL,St(MErrFClose),FileName); SysErrMsg(sParfileName); } #endif #if !defined(SILENT) || defined(RARDLL) Throw(FATAL_ERROR); #endif }
bool ErrorHandler::AskRepeatWrite(const char *FileName,const wchar *FileNameW,bool DiskFull) { #if !defined(SILENT) && !defined(_WIN_CE) if (!Silent) { SysErrMsg(); mprintf("\n"); Log(NULL,St(DiskFull ? MNotEnoughDisk:MErrWrite),FileName); return(Ask(St(MRetryAbort))==1); } #endif return(false); }
void ErrorHandler::SeekError(const char *FileName) { #ifndef SILENT if (!UserBreak) { ErrMsg(NULL,St(MErrSeek),FileName); SysErrMsg(); } #endif #if !defined(SILENT) || defined(RARDLL) Throw(FATAL_ERROR); #endif }
void ErrorHandler::CloseError(const char *FileName,const wchar *FileNameW) { #ifndef SILENT if (!UserBreak) { ErrMsg(NULL,St(MErrFClose),FileName); SysErrMsg(); } #endif #if !defined(SILENT) || defined(RARDLL) Throw(RARX_FATAL); #endif }
bool ErrorHandler::AskRepeatRead(const wchar *FileName) { #if !defined(SILENT) && !defined(SFX_MODULE) if (!Silent) { SysErrMsg(); bool Repeat=uiAskRepeatRead(FileName); if (!Repeat) // Disable shutdown if user pressed Cancel in error dialog. DisableShutdown=true; return Repeat; } #endif return false; }
void ErrorHandler::CreateErrorMsg(const char *ArcName,const wchar *ArcNameW,const char *FileName,const wchar *FileNameW) { #ifndef SILENT if (FileName!=NULL) Log(ArcName,St(MCannotCreate),FileName); Alarm(); #if defined(_WIN_ALL) && !defined(_WIN_CE) && defined(MAX_PATH) CheckLongPathErrMsg(FileName,FileNameW); #endif SysErrMsg(); #endif }
bool ErrorHandler::AskRepeatWrite(const wchar *FileName,bool DiskFull) { #ifndef SILENT if (!Silent) { // We do not display "repeat write" prompt in Android, so we do not // need the matching system error message. SysErrMsg(); bool Repeat=uiAskRepeatWrite(FileName,DiskFull); if (!Repeat) // Disable shutdown if user pressed Cancel in error dialog. DisableShutdown=true; return Repeat; } #endif return false; }
void ErrorHandler::CreateErrorMsg(const char *ArcName,const char *FileName) { #ifndef SILENT Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotCreate),FileName); Alarm(); /*#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) && defined(MAXPATH) if (GetLastError()==ERROR_PATH_NOT_FOUND) { int NameLength=strlen(FileName); if (!IsFullPath(FileName)) { char CurDir[NM]; GetCurrentDirectory(sizeof(CurDir),CurDir); NameLength+=strlen(CurDir)+1; } if (NameLength>MAXPATH) { Log(ArcName && *ArcName ? ArcName:NULL,St(MMaxPathLimit),MAXPATH); } } #endif*/ SysErrMsg(); #endif }
void ErrorHandler::CreateErrorMsg(const wchar *ArcName,const wchar *FileName) { uiMsg(UIERROR_FILECREATE,ArcName,FileName); SysErrMsg(); SetErrorCode(RARX_CREATE); }
void ErrorHandler::ReadErrorMsg(const wchar *ArcName,const wchar *FileName) { uiMsg(UIERROR_FILEREAD,ArcName,FileName); SysErrMsg(); SetErrorCode(RARX_FATAL); }
void ErrorHandler::WriteErrorMsg(const wchar *ArcName,const wchar *FileName) { uiMsg(UIERROR_FILEWRITE,ArcName,FileName); SysErrMsg(); SetErrorCode(RARX_WRITE); }
int main (int argc, char *argv[]) { char * inputfile; // job dispatch file FILE * inputliststream; PcbPtr inputqueue = NULL; // input queue buffer PcbPtr currentprocess = NULL; // current process // PcbPtr process = NULL; // working pcb pointer int timer = 0; // dispatcher timer // 0. Parse command line if (argc == 2) inputfile = argv[1]; else PrintUsage (stderr, argv[0]); // 1. Initialize dispatcher queue; // (already initialised in assignments above) // 2. Fill dispatcher queue from dispatch list file; if (!(inputliststream = fopen(inputfile, "r"))) { // open it SysErrMsg("could not open dispatch list file: ", inputfile); exit(2); } PcbPtr nextPCB; while (!feof(inputliststream)) { // put processes into input_queue nextPCB = createnullPcb(); if(fscanf(inputliststream, "%d, %d, %d, %d, %d, %d, %d, %d", &(nextPCB->arrivaltime), &(nextPCB->priority), &(nextPCB->remainingcputime), &(nextPCB->mbytes), &(nextPCB->req.printers), &(nextPCB->req.scanners), &(nextPCB->req.modems), &(nextPCB->req.cds) )!= 8){ free(nextPCB); continue; } nextPCB->status = PCB_INITIALIZED; inputqueue = enqPcb(inputqueue, nextPCB); } // 3. Start dispatcher timer; // (already set to zero above) // 4. While there's anything in the queue or there is a currently running process: while (inputqueue || currentprocess ) { if(currentprocess){ (currentprocess->remainingcputime) -= 1; if(currentprocess->remainingcputime == 0){ // if(prevprocess == NULL){ // // this would have to be the first/only process, or head of the queue // // that would mean the last process added would be the previous process // nextPCB->next = currentprocess->next; // }else { // prevprocess->next = currentprocess->next; // } //send SIGINT to terminate process terminatePcb(currentprocess); free(currentprocess); currentprocess = NULL; } } if (!currentprocess && inputqueue && inputqueue->arrivaltime <= timer){ currentprocess = deqPcb(&inputqueue); if(currentprocess) startPcb(currentprocess); } sleep(1); timer++; } // 5. Exit exit (0); }
int main (int argc, char *argv[]) { char * inputfile; // job dispatch file FILE * inputliststream; PcbPtr inputqueue = NULL; // input queue buffer PcbPtr currentprocess = NULL; // current process PcbPtr process = NULL; // working pcb pointer int timer = 0; // dispatcher timer // 0. Parse command line if (argc == 2) inputfile = argv[1]; else PrintUsage (stderr, argv[0]); // 1. Initialize dispatcher queue; // (already initialised in assignments above) // 2. Fill dispatcher queue from dispatch list file; if (!(inputliststream = fopen(inputfile, "r"))) { // open it SysErrMsg("could not open dispatch list file:", inputfile); exit(2); } while (!feof(inputliststream)) { // put processes into input_queue process = createnullPcb(); if (fscanf(inputliststream,"%d, %d, %d, %d, %d, %d, %d, %d", &(process->arrivaltime), &(process->priority), &(process->remainingcputime), &(process->mbytes), &(process->req.printers), &(process->req.scanners), &(process->req.modems), &(process->req.cds)) != 8) { free(process); continue; } process->status = PCB_INITIALIZED; inputqueue = enqPcb(inputqueue, process); } // 3. Start dispatcher timer; // (already set to zero above) // 4. While there's anything in the queue or there is a currently running process: while(inputqueue != NULL || currentprocess != NULL){//begin while // i. If a process is currently running; if(currentprocess != NULL){//begin if // a. Decrement process remainingcputime; currentprocess->remainingcputime--; // b. If times up: if(currentprocess->remainingcputime <=0){//begin if1 // A. Send SIGINT to the process to terminate it; currentprocess = terminatePcb(currentprocess); // B. Free up process structure memory free(currentprocess); printf("Successful"); }//end if1 }//end if // ii. If no process now currently running && // dispatcher queue is not empty && // arrivaltime of process at head of queue is <= dispatcher timer: if(currentprocess == NULL && inputqueue != NULL && inputqueue->arrivaltime <= timer){//begin if // a. Dequeue process and start it (fork & exec) // b. Set it as currently running process; process = deqPcb(&inputqueue); currentprocess = startPcb(process); }//end if // iii. sleep for one second; sleep(1); // iv. Increment dispatcher timer; timer++; // v. Go back to 4. continue; }//end while // 5. Exit exit (0); }
char *FmtStr( char *buff, const char *fmt, va_list args ) { char *ptr; unsigned len; long val; address addr; char *res; sym_handle *sym; char save_buff[UTIL_LEN + 1]; while( *fmt != NULLCHAR ) { if( *fmt != '%' ) { *buff = *fmt; ++buff; } else { ++fmt; switch( *fmt ) { case 'c': val = va_arg( args, int ); *buff++ = val; break; case 's': ptr = va_arg( args, char * ); buff = StrCopy( ptr, buff ); break; case 't': ptr = va_arg( args, char * ); len = va_arg( args, unsigned ); memcpy( buff, ptr, len ); buff += len; break; case 'l': addr = va_arg( args, address ); buff = StrAddr( &addr, buff, TXT_LEN ); // nyi - overflow? res = LineAddr( &addr, save_buff, sizeof( save_buff ) ); if( res != NULL ) { *buff++ = '('; buff = StrCopy( save_buff, buff ); *buff++ = ')'; } break; case 'A': addr = va_arg( args, address ); buff = UniqStrAddr( &addr, buff, TXT_LEN ); // nyi - overflow? break; case 'a': addr = va_arg( args, address ); buff = StrAddr( &addr, buff, TXT_LEN ); // nyi - overflow? break; case 'p': addr = va_arg( args, address ); buff = AddrToIOString( &addr, buff, TXT_LEN ); // nyi - overflow? break; case 'e': val = va_arg( args, unsigned ); buff = SysErrMsg( val, buff ); break; case 'U': buff = CnvULongDec( va_arg( args, unsigned long), buff, TXT_LEN ); break; case 'd': val = va_arg( args, int ); buff = CnvLongDec( val, buff, TXT_LEN ); break; case 'u': val = va_arg( args, unsigned ); buff = CnvULongDec( val, buff, TXT_LEN ); break; case '%': *buff++ = '%'; break; case 'o': val = va_arg( args, long ); if( val < 0 ) { *buff++ = '-'; val = -val; } else { *buff++ = '+'; } buff = AddHexSpec( buff ); buff = CnvULongHex( val, buff, TXT_LEN ); break; case 'S': sym = va_arg( args, sym_handle * ); buff += SymName( sym, NULL, SN_SOURCE, buff, TXT_LEN ); break; } } ++fmt; } *buff = NULLCHAR; return( buff ); }
void ErrorHandler::OpenErrorMsg(const wchar *ArcName,const wchar *FileName) { uiMsg(UIERROR_FILEOPEN,ArcName,FileName); SysErrMsg(); SetErrorCode(RARX_OPEN); }
int main (int argc, char *argv[]) { char * inputfile; // job dispatch file FILE * inputliststream; PcbPtr inputqueue = NULL; // input queue buffer PcbPtr rrqueue = NULL; // round-robin queue PcbPtr currentprocess = NULL; // current process PcbPtr process = NULL; // working pcb pointer int timer = 0; // dispatcher timer int quantum = QUANTUM; // current time-slice quantum // 0. Parse command line if (argc == 2) inputfile = argv[1]; else PrintUsage (stderr, argv[0]); // 1. Initialize dispatcher queue; // (already initialised in assignments statements above above) // 2. Fill dispatcher queue from dispatch list file; if (!(inputliststream = fopen(inputfile, "r"))) { // open it SysErrMsg("could not open dispatch list file:", inputfile); exit(2); } while (!feof(inputliststream)) { // put processes into input_queue // your code goes here // don't forget to initialize the PCB status // and put PCB on the queue } // 3. Start dispatcher timer; // (already set to zero above) // 4. While there's anything in any of the queues or there is a currently running process: while (inputqueue || rrqueue || currentprocess ) {// i'll give you this outer loop, now do the rest // i. Unload any pending processes from the input queue: // While (head-of-input-queue.arrival-time <= dispatcher timer) // dequeue process from input queue and enqueue on RR queue // ii. If a process is currently running; // a. Decrement process remainingcputime; // b. If times up: // A. Send SIGINT to the process to terminate it; // B. Free up process structure memory // c. else if other processes are waiting in RR queue: // A. Send SIGTSTP to suspend it; // B. Enqueue it back on RR queue; // iii. If no process currently running && RR queue is not empty // a. Dequeue process from RR queue // b. If already started but suspended, restart it (send SIGCONT to it) // else start it (fork & exec) // c. Set it as currently running process; // iv. sleep for quantum; // v. Increment dispatcher timer; // vi. Go back to 4. } // 5. Exit exit (0); }
int main (int argc, char *argv[]) { char * inputfile; // job dispatch file FILE * inputliststream; PcbPtr inputqueue = NULL; // input queue buffer PcbPtr inputqueue_tail = NULL; PcbPtr curr = NULL; // for creating queue PcbPtr currentprocess = NULL; // current process PcbPtr process = NULL; // working pcb pointer int timer = 0; // dispatcher timer char buffer[75]; // for reading current line of file int notNeeded[3]; // for storing the unneeded arguements of input line // 0. Parse command line if (argc == 2) inputfile = argv[1]; else PrintUsage (stderr, argv[0]); // 1. Initialize dispatcher queue; // (already initialised in assignments above) // 2. Fill dispatcher queue from dispatch list file; if (!(inputliststream = fopen(inputfile, "r"))) { // open it SysErrMsg("could not open dispatch list file:", inputfile); exit(2); } inputqueue = createnullPcb(); curr = inputqueue; while (!feof(inputliststream)) { // put processes into input_queue // your code goes here // don't forget to initialize the PCB status // and put PCB on the queue // MH DONE curr->next = malloc(sizeof(Pcb)); curr->args[0] = DEFAULT_PROCESS; curr->args[1] = NULL; fgets(buffer,sizeof(buffer),inputliststream); sscanf(buffer, "%d, %d, %d, %d", &curr->arrivaltime, &curr->priority, &curr->remainingcputime, &curr->mbytes ); curr = curr->next; } inputqueue_tail = curr; // 3. Start dispatcher timer; // (already set to zero above) // 4. While there's anything in the queue or there is a currently running process: while (inputqueue || currentprocess ) {// i'll give you this outer loop, now do the rest /* i. If a process is currently running; a. Decrement process remainingcputime; b. If times up: A. Send SIGINT to the process to terminate it; B. Free up process structure memory ii. If no process currently running && dispatcher queue is not empty && arrivaltime of process at head of queue is <= dispatcher timer: a. Dequeue process and start it (fork & exec) b. Set it as currently running process; iii. sleep for one second; iv. Increment dispatcher timer; v. Go back to 4. */ //If a process is currently running; if(currentprocess) { //a. Decrement process remainingcputime; currentprocess->remainingcputime = currentprocess->remainingcputime - 1; // b. If times up: if(currentprocess->remainingcputime == 0 ) //A. Send SIGINT to the process to terminate it; //B. Free up process structure memory if(terminatePcb(currentprocess)!=NULL) free(currentprocess); } /* ii. If no process currently running && dispatcher queue is not empty && arrivaltime of process at head of queue is <= dispatcher timer: a. Dequeue process and start it (fork & exec) b. Set it as currently running process; */ if(!currentprocess && inputqueue!=NULL && inputqueue->arrivaltime < timer) { PcbPtr dequed = deqPcb(inputqueue); currentprocess = startPcb(dequed); } //iii. sleep for one second; sleep(1000); //increment dispatch timer timer++; /*printf("current process: %d, remainingcputime: $d, dispatch timer: $d", currentProcess->pid, currentProcess->remainingcputime, timer);*/ } // 5. Exit exit (0); }
int main (int argc, char *argv[]) { char * inputfile; // job dispatch file FILE * inputliststream; PcbPtr inputqueue = NULL; // input queue buffer PcbPtr fbqueue[N_FB_QUEUES]; // feedback queues PcbPtr currentprocess = NULL; // current process PcbPtr process = NULL; // working pcb pointer int timer = 0; // dispatcher timer int quantum = QUANTUM; // current time-slice quantum int i; // working index // 0. Parse command line if (argc == 2) inputfile = argv[1]; else PrintUsage (stderr, argv[0]); // 1. Initialize dispatcher queues; for (i = 0; i < N_FB_QUEUES; fbqueue[i++] = NULL); // 2. Fill dispatcher queue from dispatch list file; if (!(inputliststream = fopen(inputfile, "r"))) { // open it SysErrMsg("could not open dispatch list file:", inputfile); exit(2); } while (!feof(inputliststream)) { // put processes into input_queue process = createnullPcb(); if (fscanf(inputliststream,"%d, %d, %d, %d, %d, %d, %d, %d", &(process->arrivaltime), &(process->priority), &(process->remainingcputime), &(process->mbytes), &(process->req.printers), &(process->req.scanners), &(process->req.modems), &(process->req.cds)) != 8) { free(process); continue; } process->status = PCB_INITIALIZED; inputqueue = enqPcb(inputqueue, process); } // 3. Start dispatcher timer; // (already set to zero above) //initialize memory MabPtr memall = createnullMab(1024); //split memory into "protected" Real Time process memory and User Memory MabPtr rtmem = memSplit(memall, 64); MabPtr mem = rtmem->next; //work with "mem" as user memory area mem->justused = 1; //initialize, the "justused" represents the most recently used, and the algorithm assumes one exists no matter what PcbPtr feedbackpending = NULL; // processes waiting for memory // 4. While there's anything in any of the queues or there is a currently running process: while (inputqueue || (CheckQueues(fbqueue) >= 0) || currentprocess ) { // i. Unload any pending processes from the input queue: // While (head-of-input-queue.arrival-time <= dispatcher timer) // dequeue process from input queue and and enqueue on feebackpending queue while (inputqueue && inputqueue->arrivaltime <= timer) { process = deqPcb(&inputqueue); // dequeue process process->status = PCB_READY; // set pcb ready process->priority = 0; // override any priority feedbackpending = enqPcb(feedbackpending, process); // & put on queue } PcbPtr nextprocess = feedbackpending; //unload pending processes from user job queue: //while (feedbackpending->mbytes is free somewhere in user mem: while(feedbackpending && memChk(mem, feedbackpending->mbytes)){ nextprocess = deqPcb(&feedbackpending); // dequeue process from user job queue nextprocess->memoryblock = memAlloc(mem, nextprocess->mbytes); // allocate memory to the process nextprocess->priority = 0; fbqueue[nextprocess->priority] = enqPcb(fbqueue[nextprocess->priority], nextprocess); } puts("got it"); // iii. If a process is currently running; if (currentprocess) { currentprocess->remainingcputime -= quantum; if (currentprocess->remainingcputime <= 0) { terminatePcb(currentprocess); memFree(currentprocess->memoryblock); free(currentprocess); currentprocess = NULL; // c. else if other processes are waiting in feedback queues: } else if (CheckQueues(fbqueue) >= 0) { suspendPcb(currentprocess); if (++(currentprocess->priority) >= N_FB_QUEUES) currentprocess->priority = N_FB_QUEUES - 1; fbqueue[currentprocess->priority] = enqPcb(fbqueue[currentprocess->priority], currentprocess); currentprocess = NULL; } } // iv. If no process currently running && feedback queues are not empty: if (!currentprocess && (i = CheckQueues(fbqueue)) >= 0) { currentprocess = deqPcb(&fbqueue[i]); startPcb(currentprocess); } // v. sleep for quantum; quantum = currentprocess && currentprocess->remainingcputime < QUANTUM ? currentprocess->remainingcputime : !(currentprocess) ? 1 : QUANTUM; sleep(quantum); timer += quantum; } exit (0); }