Solved

F*S*M T*ime

Posted on 2008-10-13
2
171 Views
Last Modified: 2012-05-05
I want to implement an F*S*M  and when a "job" is at one state for some time ,for example 1 min and then go to other state.The problem is that i don't know how to implement the time(clock) of this  system.
0
Comment
Question by:Tom211
  • 2
2 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 22709389
You want a delay of 1 minute ?

You can use the standard library for that, something like below (note that it's a busy wait, so likely not the preferred way to do it).

Or you can use platform dependent functionality, like sleep or usleep (Linux), Sleep (Windows), ...
What platform are you on ?
time_t tstart = time(0);
time_t tend = time(0);
while (difftime(tend, tstart) < 60.0f) {   // <--- one minute
  // busy wait
}

Open in new window

0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 50 total points
ID: 22709394
The code sample should have been like this of course (otherwise you'd likely have an infinite loop) :
time_t tstart = time(0);
time_t tend = time(0);
while (difftime(tend, tstart) < 60.0f) {   // <--- one minute
  // busy wait
  tend = time(0);
}

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question