Questions with _disable() and _enable().

I have some troubles with _disable() and _enable() system calls now. My program is like below:

void DE_Function() //Call _disable() and _enable(), and print.

       printf( "\n---> Enterd DE_Function...\n" );
       delay( 20000 );
       printf( "\n---> Out from DE_Function...\n" );
void ThreadMain() //My thread's main function.
      printf( "\n     Thread...\n" );
      exit( 0 );
void main()
      tfork( ... );//Create the thread calls DE_Function().
      printf( "\nParent...\n" );
      delay( 1000 );

While it performed, i got the informations, like:

I was confused by that!

What’s the use of _disable() and _enable()? I think the codes surrounded by _disable() and _enable() counld not be performed by more than once at the same time. But what’s the matter of the displays above?

Later, i sent SIGUSR1 signal to the main process, and it handled it, and DE_Function returned immediately! Can _disable() ignore all of signals?

Thanks in advance.

My guess is the delay() causes interrupts to be re-enabled, and possibly printf() does too.

If _disable() in QNX 4.x is performing a real interrupt disable then it should be used very carefully, ie: Only for required atomic operations.

Any kernel calls (which printf ends up doing) enable interrupts. Using _disable() is usually a very bad thing.

Think about it. If you were to disable interrupts, the kernel could not manage the timer require by the delay function. Furtheur more printf sends messages to Dev.* which couldn’t run if interrupts are disable since it also means disabling scheduling indirectly.

Don’t use tfork/exit for you thread use _beginthread and _endthread, look up the documentation for tfork it does mention it.

I have reached the conclusion that we have told this person enough times that he should not be using threads in QNX4. I, for one, have decided not to answer any more questions which so obviously stem from him continuing to use threads.


I did asked myself the same question. Is somebody asking from trouble worth helping. My conclusion so far is that as long as the “conversation” is enjoyable, that the person isn’t blaming everybody else for their own ignorance, and the person show some level of appreciation for the help given (for free) in here, then i’ll keep on helping.

I do think that Hmizly took on a challenge that is beyond his current capability. Yet I remember doing the same which to some degree has given me indepth knowledge of some of the inner working of QNX.


I REALLY REALLY REALLY know that it’s dangerous using threads in QNX4!
But i have to do that! All of projects of our company are all for QNX4 and i have to work with threads. I want to translate all of the codes into QNX6.x too, but there are more than 500 thousand line codes and only 3 programmers in our company!

So, i am so sorry to ask some questions refering to threads.

I have so few informations of QNX, and i have to ask lots of questions in openQnx forum.

You have given me much help and thanks.


Why do you think that you have to work with threads?

I must have some modules to deal with the hardware, the Cable Modems, the BPKM, the LAN and QNX itself.

I think threads might be the best way to complete all of the jobs.

Do you have any advice?

Sure. Use multiple processes with messaging, unless you are bandwidth limited by messaging.

btw: threads in QNX4 can be thought of as separate processes with automatic data sharing, and if used in this way, there is absolutely nothing wrong with them (in fact this results in less code than manually setting up shared memory and placing data structures in it, etc., etc.).

Reggie. I don’t think telling an unexperience QNX4 person that “there is absolutely nothing wrong with them” is a good idea…