Solved

F*S*M T*ime

Posted on 2008-10-13
2
168 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

770 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