I have a little challenge for you all. I am coding using a fairly limited language with a syntax similar to that of C. It does not support pointers or structures, but it does however support some rather sophisticated multitasking facilities, like semaphores, ques and RPC. It has a global and a module scope. You cannot declare an array inside a function, only single variables. The array has to be either module or global.
Now my problem is, I have a function for reading a value from an external device. This function is blocking, and the code that I am going to use this value in, is running in foreground. I cannot put a blocking function inside a foreground task. This foreground task runs every 250ms, and there is many instances of it.
Now, I am able to create a new task that can perform this reading in the background, but I am a little clueless as to how I could do this the most efficient way.
The synopsises of the que functions are as follows:
QueOpen(STRING queName, INT mode)
mode can be either:
- 0 - Open existing que
- 1 - Create new que
- 2 - Attempt to open new que and create if it is not existing
QueWrite(INT queHandle, INT type, STRING string)type and string can be anything you want. These have no meaning to the que.
QueRead(INT queHandle, INT type, STRING string, INT mode)string and type will get their respective values from the que, mode has two valid values:
- 0 - None blocking mode
- 1 - Wait for an element to come into the Que if it's empty.
QuePeek(INT queHandle, INT type, STRING string, INT mode)
- 1 - Search for a matching string (string)
- 2 - Search for a matching number (type)
- 4 - Search for a matching string and use case-sensitive search (string)
- 8 - If the element is found, remove it from the que
- 16 - Search the que, in order, for the element at the offset specified by Type
QueLength(queHandle)Get the length of the que
QueClose(queHandle)Closes the cue
I need to find a way to put in some elements in the que from the continously running forground task based on a parameter supplied to it, read the que from a continously running task that performs the reading of the value from the external device, put it back in the que and I'll have to read it back into the forground task.
Any suggestions or ideas on how to accomplish this?
Thanks


Sign In
Create Account

Back to top









