Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4171996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:30:36+00:00 2026-05-21T00:30:36+00:00

I am looking for some implementation (ideas) of the one-dimensional state table in C.

  • 0

I am looking for some implementation (ideas) of the one-dimensional state table in C. The transition are kind of objects (struct) that contain:

  • Pointer to the guard function
  • Next state
  • List of pointers to action functions.

I am looking at C state-machine design but in my case I have multiple conditions to form an event.
Is there any generic approach or simple FSM sw processor suitable for embedded system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T00:30:36+00:00Added an answer on May 21, 2026 at 12:30 am

    The usual approach is to store pointer to a conditional function.
    You implement the set of conditions as separate functions, and attach a pointer to the right condition in the table. Each function tests for given set of conditions. You iterate through the list till one of pointed functions returns true. Of course “current state” can be used as part of conditions, which removes the need for 2d array.

      struct {
           bool(*test)();           //the condition
           void(*onsuccess)();      //event
      } condition;
    

    This may be inefficient if the conditions repeat a lot in a chain like:

      ev1: (a && b && c)
      ev2: (a && !b && c)
      ev3: (a && b && d)
      ev4: (a && !b && !c)
      ev5: (!a)
    

    (most events tests for a separately, if testing for a is computationally expensive it will take much more CPU time than necessary).

    In this case you’d have to remap the condition_set -> event list into a single decision tree – much harder to maintain but more CPU-efficient:

       a:
           b:
               c: ev1
               d: ev3
          !b:
               c: ev2
              !c: ev4
      !a: ev5
    

    This of course cannot be a simple 1-dimensional list any more, but requires a tree-like structure instead, say, branched linked list:

      struct {
           bool(*test)();           //the condition
           void(*onsuccess)();      //event (if any)
           condition* next_sibling; //other conditions dependent on parent but independent from this one,
           condition* first_child;  //other conditions dependent on this one,
      } condition;
    

    NULL on any of the pointers means “no such item” (except on “test” which can’t be null). And of course recursion required to traverse the list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for some implementation ideas here. I am trying to design a custom polling
Looking for some sample code (C#) for a simple thread pool implementation. I found
Looking at some code I'm maintaining in System Verilog I see some signals that
I'm looking for some Best Practices for automating the deployment of Stored Procedures/Views/Functions/Table changes
I'm looking for some software that allows me to control a server based application,
I am looking at the implementation of an API that I am using. I
I'm looking for a opensource library that has an implementation of a composite list.
I'm looking for a way to create a simple HTML table that can be
Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like
Looking for some direction here as I'm running into some migration problems. We have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.