Execution of Sleep () in Xlib programming

I have used a sleep() in the below section of code. However, to my surprise I found that sleep() is executed first and then the two lines used for printing pixels are executed. That means, I am getting both the pixels printed out at the same time after a 1 second wait in the beginning. However, I was supposed to get something like this, print a pixel, then wait for 1 second, and then print the next pixel. What could be the reason? Well, I am writing a X11 server display program.

  ----------------  other header files
  int main ()
  ------------variables and few lines of code for X11 graphics


  ---------- Few other stuffs

Source: unix

Leave a Reply