Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to pause the execution of a C program?

Status
Not open for further replies.

nitrojacob

Member level 2
Joined
Jun 6, 2008
Messages
42
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,288
Activity points
1,537
Can i halt or pause a C program(for x86), so that i can return execution from that point onwards after interrupt occurs(and after servicing it). (Just like entering the idle mode in 8051 microcontrollers?)
 

Pausing a C program?

i dob't remember exacly that in C System "pause" works. try it
 

Re: Pausing a C program?

Saying on this exactly, you don have any pause options while executing C programs.
The "Pause Break" button in the keyboard can exit ur program execution but you cannot pause it and regain it...
Don confuse this with Microcontrollers. this is wholly different....









--------------------------------------------------
**broken link removed** = "HughesNet Blog"
**broken link removed** = "Satellite Internet Blog"
 

Re: Pausing a C program?

What i meant is to pause the program by calling a function. The getch() function works in this way. Once the function is called, it will pause/halt the program until a keyboard interrupt (generated by the user hitting a key). What i want is to modify it for other interrupts (eg. serial interrupt). If anybody can find the source code of getch() function, please post it.

Thanks.

Jacob.
 

Re: Pausing a C program?

Pausing requires some other process to execute or somehow to halt the system. The former is OS dependent. So some system calls, as i see in Linux now, is required for such jobs.
 

Re: Pausing a C program?

You can pause basically in two ways; interrupt based and polling based.

With a function like getchar(), it will keep on polling to receive the next character and as soon as it receives that, it completes and exits. In this case while you have paused your program, you are doing nothing useful and just wasting CPU cycles waiting for the input.

Interrupt based pause can be implemented using an interrupt service routine (ISR). Your ISR will serve the specific interrupt on which you want to wait. From that ISR you can set an event (or similar allowed object). The program that is intended to be paused should have been waiting on that event. This requires a thread based application.

You can adopt these basic principles to your select OS and application.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top