Recent

Author Topic: ERROR_TOO_MANY_SEMAPHORES  (Read 7723 times)

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
ERROR_TOO_MANY_SEMAPHORES
« on: July 01, 2010, 08:00:28 am »
I need of know the causes of this bug.
The bug is ERROR_TOO_MANY_SEMAPHORES.
Here is the code:
Code: Pascal  [Select][+][-]
  1. procedure ler;
  2. begin
  3. dir := c + '\carros.sgs';
  4.   system.Assign(carrosfile,dir);
  5.   system.Reset(carrosfile);
  6.   system.seek(carrosfile,0);
  7.   read(carrosfile,tmpcarros);
  8.    for i := 2 to tmpcarros.total do begin
  9.   system.seek(carrosfile, i-1);
  10.   read(carrosfile, carrosarray[i-1]);
  11.   end;
  12.   system.Close(carrosfile);
  13. end;
  14.  
« Last Edit: July 01, 2010, 08:02:14 am by dicas3d »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #1 on: July 01, 2010, 08:10:23 am »
It is a Windows message.

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #2 on: July 01, 2010, 08:18:48 am »
Yes I know it. But this is a method created by me to don't replicate the code if I understand well what you said.
But did you talk about the how i put the colour with colours. I try it on this link http://www.portugal-a-programar.org/forum/index.php/topic,8185.0.html. If you don't talk Portuguese is a tag CODE(with[ and ])

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #3 on: July 01, 2010, 08:59:14 am »
ERROR_TOO_MANY_SEMAPHORES is not a Lazarus message.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #4 on: July 01, 2010, 10:53:14 pm »
How do you get the error message? To the best of my knowledge neither lazarus nor FPC has that message, it's a Windows message indeed.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4468
  • I like bugs.
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #5 on: July 01, 2010, 11:34:14 pm »
You can get that error when using threads and forgetting to define "UseCThreads".
Happens on Linux at least (I haven't run Lazarus on Windows yet).

dicas3d, does the program use threads?

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #6 on: July 01, 2010, 11:58:38 pm »
The program don't use threads and now I discover the error. It happens because the read pass the end of file.
This is the correct code:
Code: Pascal  [Select][+][-]
  1. procedure ler;
  2. begin
  3. dir := c + '\carros.sgs';
  4.   system.Assign(carrosfile,dir);
  5.   system.Reset(carrosfile);
  6.   read(carrosfile,tmpcarros);
  7.    for i := 2 to tmpcarros.total - 1 do begin
  8.   system.seek(carrosfile, i-1);
  9.   read(carrosfile, carrosarray[i-1]);
  10.   end;
  11.   system.Close(carrosfile);
  12. end;  
  13.  

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #7 on: July 02, 2010, 12:49:38 am »
I need to replace the condition of the cycle for another more suitable.
That read all lines of the file without write in the file the number of lines. What structure I need?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: ERROR_TOO_MANY_SEMAPHORES
« Reply #8 on: July 02, 2010, 01:05:50 am »
Code: [Select]
while not Eof(file) do

 

TinyPortal © 2005-2018