0

Ok, I'm working on my Operating Systems assignment. I need to write a microkernel which is able to do some basic stuff with threads, semaphores, events, etc. BCC 3.1 is imitating my system environment. Classical debugging is really not of use. I'm debugging in cout style. Problem is weird behavior of cout. It writes out in blocks or something. If I do, like, 40 couts it writes everything out. If I do 39 of them, it doesn't write any of them. On other hand if i do between 40 and 79 couts, it still writes only first 40, but if I do 80 of them, they're all ok, etc. Numbers are not exact, I'm not sure what's the number really. But I have also noticed that changing the length of string that is cout-ed effects the same way. Only I don't know how many characters equals one cout call. Additional information available upon request. Thanks in forward.

Johan
  • 74,508
  • 24
  • 191
  • 319
maricn
  • 593
  • 1
  • 6
  • 21

1 Answers1

1

sounds like buffering regardless of the fact std::cout shouldn't buffer output. in any case you can try flushing cout by

std::cout.flush();

or

std::cout << std::flush;

or

std::cout << std::endl;

or even by disabling buffering:

std::cout.rdbuf()->pubsetbuf(0, 0);

Andriy Tylychko
  • 15,967
  • 6
  • 64
  • 112
  • no effect at all from flushing... i've tried last line, but got compiler error: pubsetbuf is not a member of streambuf. – maricn Jul 27 '11 at 13:47