Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/20/01 09:09
Read: times


 
#14238 - RE: CPU reset by SW
Oleg:

I think that setjmp() and longjmp() are dfined by ANSI-C, so you should find a more detailed info in any book about C-language.

I have used these functions only once, to resume from communication errors in a PC application. The basic idea is:

1) Insert a call to setjmp() in the point X in your program where you want to jump later. This function saves some information about the current state of the system (for example the stack state).

2) Call longjmp() anywhere in your code to resume to X. In fact this resumes the execution in the first instruction after setjmp().

The main difference between goto() and longjmp() is that the latter can be used to jump outside the function that invokes it. And the system still reamins, or it should, in a stable state. Of course the current task is left and its variables lost. The restore process is carried out esentially resetting the stack to the position it had when yo called setjmp() and loading the program counter to point the next instruction after that call.

It is usually said that C is a language with little resources for error management, and the pair setjmp()-longjmp() are a basic way to recover from errors or other exceptions.

Regards,

Alfredo del Rio.

List of 18 messages in thread
TopicAuthorDate
CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: Michal: CPU reset by SW            01/01/70 00:00      
RE: Sans: CPU reset by SW            01/01/70 00:00      
RE: Sans: CPU reset by SW            01/01/70 00:00      
RE:San Brgmns: CPU reset by SW            01/01/70 00:00      
RE: RE:San Brgmns: CPU reset by SW            01/01/70 00:00      
RE: Sans: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      
RE: CPU reset by SW            01/01/70 00:00      

Back to Subject List