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 9191533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:42:25+00:00 2026-06-17T20:42:25+00:00

Imagine a device full of sensors. Now, in case a sensor x detects something,

  • 0

Imagine a device full of sensors. Now, in case a sensor x detects something, something should happen. Meanwhile, in case something else is detected, like two sensors detects two different things, then, this device must behave differently.

From webdesign (so javascript) I learned about Events, for example (using jquery) $(".x").on("click", function(){}) or from angularjs $scope.watch("name_of_var", function()).

Is there any possibility to replicate this behaviour in C, without using complex libraries?

  • 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-06-17T20:42:26+00:00Added an answer on June 17, 2026 at 8:42 pm

    I would assume you’re owning an embedded system with access to interrupts or a major event loop in a separate thread, otherwise this isn’t possible..

    A basic model for event handling is here:

    #define NOEVENT 0
    
    typedef void *(*EventHandler)(void *);
    
    void *doNothing(void *p){/*do nothing absolutely*/ return NULL; }
    typedef struct _event{
      EventHandler handler;
    }Event, *PEvent;
    
    Event AllEvents[1000];
    unsigned short counter = 0;
    void InitEvents()
    {
        LOCK(AllEvents);
        for(int i = 0; i < 1000; i++){ 
            AllEvents[i].handler = doNothing;
        }
        UNLOCK(AllEvents);
    }
    void AddEvent(int EventType, EventHandler ev_handler)
    {
        LOCK(AllEvents);
        AllEvents[EventType].handler = ev_handler;
        UNLOCK(AllEvents);
    }
    
    void RemoveEvent(int EventType, EventHandler ev_handler)
    {
       LOCK(AllEvents);
       AllEvents[EventType] = doNothing;
       UNLOCK(AllEvents); /*to safeguard the event loop*/
    }
    
    /*to be run in separate thread*/
    void EventLoop()
    {
       int event = NOEVENT;
       EventHandler handler;
       while(1){
           while(event == NOEVENT)event=GetEvents();
           handler = AllEvents[event].handler;
           handler();/*perform on an event*/
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an instant messaging application. imagine something like skype or yahoo messenger. Now
Imagine a full Android device screen, I want it split in to two sections:
Imagine I want to draw a pyramid made of triangles. -Should I create a
Imagine you have two views with code like the following: controller_a/a.html.erb <%= content_tag(:div) do
Imagine I have a Device class. I don't want the programmer to be able
Imagine a cube-shaped piece of Swiss cheese. We model the cheese through a 20x20x20
imagine this html on a page <div id=hpl_content_wrap> <p class=foobar>this is one word and
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
Imagine an architecture composed of 2 Virtual Machines VM1 and VM2 hosted somewhere in
Imagine I've got a database with lots of data, from which users can search.

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.