本文整理汇总了C++中Halt函数的典型用法代码示例。如果您正苦于以下问题:C++ Halt函数的具体用法?C++ Halt怎么用?C++ Halt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Halt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestMemory
void TestMemory()
{
register unsigned char* i;
PutString("TESTING MEMORY A", 1, 1);
_SimUnprotect(0x4000, 0x5fff);
for(i=(char*)0x4000; i<(char*)0xEEEA; i++) {
*i=0xAA;
}
for(i=(char*)0x4000; i<(char*)0xEEEA; i++) {
if(*i!=0xAA) {
PutString("BAD MEMORY", 1, 1);
Halt("BAD MEMORY");
}
}
PutString("TESTING MEMORY B", 2, 1);
_SimUnprotect(0x4000, 0x5fff);
for(i=(char*)0x4000; i<(char*)0xEEEA; i++) {
*i=(~0xAA);
}
for(i=(char*)0x4000; i<(char*)0xEEEA; i++) {
if(*i!=(~0xAA)) Halt("BAD MEMORY");
}
PutString("MEMORY TEST COMPLETE", 3, 1);
_SimUnprotect(0x4000, 0x5fff);
for(i=(char*)0x4000; i<(char*)0xEEEA; i++) {
*i=0;
}
_SimPrintString("Memory test completed\n");
}
示例2: main
int
main()
{
SpaceId kid;
int joinval;
char *args[1];
args[0] = (char *)0;
print("PARENT exists\n");
if ((kid=Fork()) == 0) {
Exec("deepkid1", args);
print("ERROR: exec failed\n");
Halt();
}
if(kid==-1){Halt();}
print("PARENT after fork/exec; kid pid is "); printd((int)kid, ConsoleOutput);
print("\n");
print("PARENT about to Join kid\n");
joinval = Join(kid);
print(">>PARENT off Join with value of ");
printd(joinval, ConsoleOutput);
print("\n");
Exit(10);
Halt();
/* not reached */
}
示例3: step
// This is our PRAM program
// After each case x label, you can put an instruction
void step(int pc, int i, int * x, int * y, int * z)
{
int debug=0;
int writecount=0;
// printf("%d %d %d %d %d\n",pc, i, *x, *y, *z);
// i is the processor number
// *x, *y and *z are temporary registers
switch(pc)
{
case 0: *z = 0;
break;
// Init N <= g < 2N-1 and 2N <= p < 3N - 1 and 3N <= z <= 4N-1
case 1: *y = Read(i+N);
break;
case 2: *x = Read(i);
break;
case 3: *x = *x + *y;
break;
case 4: Write(i,((*x)%10));
break;
case 5: Write(i+N,((*x)>9));
break;
case 6: Write(i+2*N,(*x==9)); // p
break;
case 7: Write(3*N+i, 0);
break;
// Prefix sum the g
case 8: JumpIf(13,i<(int)pow(2,Read(3*N+i)));
break;
case 9: *x = Read(i+N) /* g */ || ( Read(i+2*N) /* p */ && Read(i+N-(int)pow(2,Read(3*N+i))) /*g' */ );
break;
case 10: Write(i+N,*x); //g
break;
case 11: *x = Read(i+2*N) && Read(i+2*N-(int)pow(2,Read(3*N+i)));
break;
case 12: Write(i+2*N,*x);
break;
case 13: Write(3*N+i,Read(3*N+i)+1); // step increment
break;
case 14: JumpIf(8,Read(3*N+i)<(int)log2(N)) ;
break;
// Sum
case 15: JumpIf(19,i==0);
break;
case 16: *x = Read(i);
break;
case 17: *y = Read(i+N-1) || Read(i+2*N-1);
break;
case 18: Write(i,(*x + *y)%10);
break;
case 19: Halt();
break;
default: Halt();
}
}
示例4: _InterruptService
void _InterruptService() {
register short i;
ExchangeRegs();
GetStackPointerASM(_UserSP);
SaveIndexes();
if(ControlRequests<0) Halt("NEGATIVE CONTROLREQUESTS");
if(!IsMultitasking()) Halt("INTERRUPT IN KERNEL MODE");
ControlRequests++;
Tick();
for(i=0; i<InterruptVectorCount; i++) {
(InterruptVector[i])();
}
Scheduler(UserSP);
Halt("OUT OF REACH");
}
示例5: main
int main()
{
int i;
OpenFileId f0, f1;
Create( "test1_f0" );
Create( "test1_f1" );
f0 = Open( "test1_f0" );
f1 = Open( "test1_f1" );
Write( "Test1: This is file 0\n", 22, f0 );
Write( "Test1: This is file 1\n", 22, f1 );
for( i = 0; i < 256; ++i ) usr_buffer_0[i] = 'A';
Write( usr_buffer_0, 128, f0 );
/* reset file pointer of f0 to the starting position */
Close( f0 );
f0 = Open( "test1_f0" );
Read( usr_buffer_1, 128, f0 );
Write( usr_buffer_1, 128, 1 ); // adding this allows the second write to work
Write( usr_buffer_1, 128, f1 );
Close( f0 );
Close( f1 );
Halt(0);
}
示例6: main
int main()
{
// Escribimos un texto indicativo sobre la consola.
char *writeStr = "Ingrese un texto:\n";
Write(writeStr, 18, ConsoleOutput);
// Leemos caracteres desde la consola hasta encontrar el "\n".
char readStr[1024], tmpChar;
int i = 0;
do {
Read(&tmpChar, 1, ConsoleInput);
readStr[i] = tmpChar;
i++;
} while (tmpChar != '\n');
// Escribimos los caracteres ingresados en la consola.
writeStr = "Usted ingreso:\n";
Write(writeStr, 16, ConsoleOutput);
Write(readStr, i, ConsoleOutput);
// Realizamos una llamada a halt para finalizar Nachos.
Halt();
}
示例7: switch
void CTestSignals::KeyComplete(TKeyCode aKey)
{
switch (aKey)
{
case EKeyEscape:
Halt();
break;
default:
switch (iState)
{
case EAllOff:
DoSignals(ERtsOn);
break;
case ERtsOn:
DoSignals(EDtrOn);
break;
case EDtrOn:
DoSignals(EAllOn);
break;
case EAllOn:
DoSignals(EAllOff);
break;
default:
break;
}
}
}
示例9: log_err
/* A kernel magic function that is only used for getting kernel context for newbie
*/
KernelContext *init_newbie_kernel(KernelContext *kernel_context, void *_prev_pcb, void *_next_pcb){
pcb_t *next_proc = (pcb_t *) _next_pcb;
//log_info("First time to init PID(%d) kernel stack!", next_proc->pid);
if(next_proc->kernel_stack_pages == NULL) {
log_err("Init kernel stack fail, pcb->kernel_stack_pages not malloc yet");
Halt();
}
next_proc->kernel_context = *kernel_context;
int rc = alloc_frame_and_copy(next_proc->kernel_stack_pages,
kernel_page_table,
GET_PAGE_NUMBER(KERNEL_STACK_BASE),
GET_PAGE_NUMBER(KERNEL_STACK_LIMIT),
kernel_memory.swap_addr);
if(rc) {
log_err("PID(%d) kernel stack cannot init", next_proc->pid);
return NULL;
}
next_proc->init_done = 1;
//print_page_table(kernel_page_table, 120, GET_PAGE_NUMBER(VMEM_0_LIMIT));
//print_page_table(next_proc->kernel_stack_pages, 0, 2);
//log_info("First time to init PID(%d) kernel stack done", next_proc->pid);
return kernel_context;
}
示例10: main
int
main()
{
SpaceId kid;
int joinval;
char *args[2];
args[0] = "huge";
args[1] = (char *)0;
if ((kid = Fork()) == 0)
Exec("huge",args);
prints("PARENT after foprk/exec; kid pid is ", ConsoleOutput);
printd((int)kid, ConsoleOutput);
prints("\n", ConsoleOutput);
prints("PARENT about to Join kid\n", ConsoleOutput);
joinval = Join(kid);
prints("PARENT off Join with value of ", ConsoleOutput);
printd(joinval, ConsoleOutput);
prints("\n", ConsoleOutput);
Halt();
/* not reached */
}
示例11: SwitchToProc
// Begin executing the specified proc.
// NOTE: place the current proc into the correct queue before calling
void SwitchToProc(PCB *next_proc, UserContext *user_context) {
TracePrintf(TRACE_LEVEL_FUNCTION_INFO, ">>> SwitchToProc()\n");
assert(user_context);
assert(next_proc);
// Save current user state
current_proc->user_context = *user_context;
TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Loading next proc context into %p\n", user_context);
TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Loading next proc PID: %d\n", next_proc->pid);
*user_context = next_proc->user_context;
// Set the TLB registers for the region 1 page table.
WriteRegister(REG_PTBR1, (unsigned int) next_proc->region_1_page_table);
WriteRegister(REG_TLB_FLUSH, TLB_FLUSH_1);
PCB *old_proc = current_proc;
current_proc = next_proc;
int rc = KernelContextSwitch(&SaveKernelContextAndSwitch, old_proc, next_proc);
if (SUCCESS == rc) {
TracePrintf(TRACE_LEVEL_DETAIL_INFO, "Succesfully switched kernel context!\n");
} else {
TracePrintf(TRACE_LEVEL_NON_TERMINAL_PROBLEM, "Failed to save kernel context!\n");
char *err_str = calloc(TERMINAL_MAX_LINE, sizeof(char));
sprintf(err_str, "KernelContextSwitch failed!!! HALTING!!!\n", current_proc->pid);
KernelTtyWriteInternal(0, err_str, strnlen(err_str, TERMINAL_MAX_LINE), user_context);
free(err_str);
Halt();
}
// Restore user state of new current process
*user_context = current_proc->user_context;
TracePrintf(TRACE_LEVEL_FUNCTION_INFO, "<<< SwitchToProc()\n");
}
示例12: coretracefunc
Nav2::~Nav2(){
coretracefunc();
Halt();
WaitNavigate2();
coreprintln("Halt and WaitNavigate2 completed..");
delete[] m_globalData->m_writable_files_path;
delete[] m_globalData->m_readonly_files_path;
delete m_errorTable;
delete mainlog;
delete m_globalData->m_logmaster;
delete m_globalData;
#ifdef __SYMBIAN32__
delete m_archGlobalData->m_timerThread;
if(m_archGlobalData->m_socketServ){
m_archGlobalData->m_socketServ->Close();
delete m_archGlobalData->m_socketServ;
m_archGlobalData->m_socketServ=NULL;
}
delete m_archGlobalData;
deleteTlsGlobalData(m_tlsGlobalData, m_tlsGlobalDataId);
#endif
//delete m_audioSyntax; - owned by AudioCtrl...
}
示例13: NewContext
void NewContext(int* SP) {
// SP for next task to go (arg #1) goes into HL
SP; FunctionArgToReg(H, L);
// Restores usermode status
SetStackPointerASM(_OldSP);
ExchangeRegs();
ReloadIndexes();
SaveContext();
// Switches to the process with stack in SP
ExchangeRegs();
GetStackPointerASM(_TempSP);
SetStackPointerREG(HL);
*CurrentSP=TempSP;
ExchangeRegs();
LoadContext();
if(ControlRequests==0) Halt("ISR IN USER MODE");
ControlRequests--;
IntsOn();
ImmediateReturn();
}
示例14: main
int
main(int argc, char **argv)
{
int i, joinval, tmp;
SpaceId kid;
char *args[1];
args[0] = (char *)0;
for (i=0; i<100000; i++) tmp++;
/* loop to delay kid initially */
if ((kid=Fork()) == 0) {
Exec("deepkid2", args);
print("ERROR: exec failed in kid\n");
Exit(100);
}
print("KID1 after exec; kid1 pid is ");
printd((int)kid, ConsoleOutput);
print("\n");
print("KID1 about to Join kid2\n");
joinval = Join(kid);
print("KID1 off Join with value of ");
printd(joinval, ConsoleOutput);
print("\n");
Exit(1);
/* Should not get past here */
print("ERROR: KID1 after Exit()\n");
Halt();
/* not reached */
}
示例15: main
int
main()
{
SpaceId kid;
int joinval;
prints("PARENT exists\n", ConsoleOutput);
kid = Fork();
if (kid != 0) {
prints("PARENT after fork; kid pid is ", ConsoleOutput);
printd((int)kid, ConsoleOutput);
prints("\n", ConsoleOutput);
joinval = Join(kid);
prints("PARENT off Join with value of ", ConsoleOutput);
printd(joinval, ConsoleOutput);
prints("\n", ConsoleOutput);
Halt();
/* not reached */
} else
Exec("kid");
}