Task/Process hängt sich scheinbar auf.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Page 2 of 6
pvs-deck
PowerUser
Avatar
Gender:
Age: 53
Homepage: pvs-deck.de
Posts: 1341
Registered: 02 / 2009
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 15.07.2022 - 18:56  ·  #9
Hello Merlin,
but I thought with tasks they run only 1x and processes run until they are interrupted or terminated (shedule).

Thorsten
Harry
Moderator
Avatar
Gender:
Location: zwischen Augsburg und Ulm
Age: 59
Posts: 2093
Registered: 03 / 2003
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 15.07.2022 - 19:33  ·  #10
Hi Thorsten,

bei 10ms Systick und Tasks/Processen und einer Priorität von 5 je Task bzw. 3 je Process:
3x10ms Main
max. 10ms je Task bis durchlaufen oder wenn du raus springst. Die Prio steuert die Anzahl der Aufrufe.
3x10ms je Process, weniger wenn du raus springst

Gruss
Harry
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1374
Registered: 03 / 2005
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 15.07.2022 - 19:57  ·  #11
Hi Thorsten.

Quote
but I thought with tasks they run only 1x and processes run until they are interrupted or terminated (shedule).


Yes, more or less. But perhaps you are missing the implications of that, or else I am missing the point of your post.

For tasks we agree (except that if a task runs out of time it terminates even if not complete). In its next time slice it starts again. So to increment a variable inside a task to measure how many timeslices have been used in this task is legitimate.

For processes, we sort of agree too, I think, but I am not sure. A suspend will cause a time slice to end, even if it is not due to end. But when the process resumes it continues where it left off. It does not start again.

Quote
Wenn ich jetzt bei einem Systick von 10 ausgehe (10ms) reden wir von max. 100 Taskaufrufen in der kompletten Summe. Es wird bei mir evtl. etwas höher liegen da ich viel mit shedule arbeite.
Aber diese Zahlen können doch gar nicht sein (siehe Bild)!


I am assuming that you are putting a variable inside a process and hoping it will measure how many time slices are involved per second, but I cannot see how that is possible. When a process reaches the end the time slice is not terminated, so the variable will be incremented whether or not the time slice has finished, and conversely not incremented even if a new time slice has been instigated. A process is not aware of how many timeslices have been executed. It is almost like having a separate processor (not quite obviously).

Or maybe it is the other way round - and you are wondering why only 20-sh for the tasks? Well, with priority 5 and systick 10ms a timeslice is 50ms so that looks about right. a fair amount of time is taken up by the scheduler itself. As I say, for processes the figure is meaningless.
pvs-deck
PowerUser
Avatar
Gender:
Age: 53
Homepage: pvs-deck.de
Posts: 1341
Registered: 02 / 2009
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 26.07.2022 - 10:58  ·  #12
Hallo,

es scheint so als ob das FileSystem oder die LogDatei auf der SDCard ein Problem hat.
Wenn man die Log-Datei dann löscht, wird eine neue angelegt und es läuft wieder.
Im Handbuch haben wir extra geschrieben "..nur im ausgeschalteten Zustand die SD-Card ziehen/stecken..." Aber wahrscheinlich wurde das nicht immer gemacht :-(

Jetzt muss ich irgendwie sicherstellen, das bei einem Defekt der Datei, diese umbenannt wird, damit eine neue Datei angelegt wird.

In den anderen Prozessen nutze ich die folgende Procedure:
Code
//---------------------------------------------------------------
// Log in Pipe  speichern
procedure LogString(const InStrLog: string[41]);
var
 xLog : byte;
 bufferLog : TLogBuch; 

begin
   bufferLog.strLogTime:=RTCZeitBlock.strLogTime;
    bufferLog.strLogDate:=RTCZeitBlock.strLogDate;
     bufferLog.strLog:=InStrLog;
      PipeSend( LogPipe, bufferLog );
end LogString;


Ich verwende für die Pipe den Type:
Code
// Logbuch Record
TLogBuch    = record
                 strlogDate     : string[6];  // strlog   01042018
                 strlogTime     : string[6];  // strlog   235920
                 strLog         : string[41]; // Logbuch String
               end;


Code
// Meldungssystem 
  LogPipe       : Pipe [8] of TLogBuch;// PIPE of byte für LOGBUCH 


Im Process StatusDisplay schaue ich dann regelmäßig nach ob etwas in der Pipe vorhanden ist, wenn ja verarbeite ich es:

Code
//---------------------------------------------------------------
// Log speichern Pipe
// V1.1944  Thorsten Deck
// 
procedure Save_LogPipe;
var
 wResBlockWrite : Word;
 dosTime, dosDate : word;
 xFor, xstrNo, strNo : byte;
 bufferLog : TLogBuch;
begin

// überprüfe Pipe

// if not LogViewActive then // sperre vom View aktiv
  LogSaveActive:= true; // sperre setzen
   
 xstrNo:= PipeStat( LogPipe );
 if xstrNo > 0 then
 
  // SD Card nicht vorhanden, dann Meldung aktiv lassen, Pipe leeren und aus der Funktion raus
 if not bMMCok then
   PipeFlush(LogPipe);
 
 else // bMMCok wenn SDCard vorhanden dann laufe normal
   SD_Error:= 0; // Setze ErrorCode auf 0
   
    sdAktive();   // Timer für SD Anzeige

    // erzeuge Datum und Zeit für Datei
    dosTime := F16_StrToTime( RTCZeitBlock.strzeit);
     dosDate := F16_StrToDate( RTCZeitBlock.strdatum );

    // Dateiname erzeugen, für jeden Monat eine eigene Datei
    //
    Datei_Name := '20'+ByteToHex(RTCZeitBlock.jahr)+ByteToHex(RTCZeitBlock.monat)+'.log';
    // Pfad setzen
     LogDir := 'log';


   lock(self);

      F16_FileAssign(Log_Datei, LogDir, Datei_Name);// Handle mit FileNamen verknüpfen
       
      
      if F16_FileExist(LogDir, Datei_Name,faAnyFile) then
        F16_FileAppend(Log_Datei);               // vorhandene Datei öffnen

      else // File Exist
        //Create_New_File(DosTime, DosDate);
         F16_FileCreate(LogDir, Datei_Name, [faArchive], dosTime, dosDate,0);
        SD_Error := 102; //DebugOut('102');
      endif; // File Exist
       // Schreibe Log-Zeile
        for xFor := 1 to xstrNo do
         PipeRecv( LogPipe, bufferLog ); // ziehe ersten Record aus Pipe
          F16_BlockWrite (Log_Datei,  @bufferLog, 1 ,wResBlockWrite );
       endfor;
         F16_FlushBufSec; // Sichere den Buffer
         
      LogRecords:= F16_FileSizeH(Log_Datei); //Anzahl der Datenrecords im File


      if not F16_FileClose(Log_Datei) then                         // File schließen
        SD_Error := 104; //DebugOut('104');
      endif; // CloseFile
      if not F16_FileSetDate(LogDir, Datei_Name, DosTime, DosDate) then // TimeStamp
        SD_Error := 105; //DebugOut('105');
      endif; // CloseFile
      if not F16_FileSetAttr(LogDir, Datei_Name, [faArchive]) then // TimeStamp
        SD_Error := 106; //DebugOut('106');
      endif; // CloseFile

  unlock(self);
      
   endif; // bMMCok
  endif; //  xstrNo
       LogSaveActive:= false; // sperre entfernen
end Save_LogPipe;


Da die Steuerung sich bei einem Defekt hier unnötig aufhält, werde ich nun diese Routine etwas umschreiben und bei einem Fehler (SD_Error > 0 ) diese Routine beenden, die Pipe leeren "PipeFlush(LogPipe);" und bMMCok auf False setzen, dadurch wird ein Fehler im Display angezeigt und die SD-Card wird nicht mehr angesprochen.

Für mich scheint es so zu sein, als ob sich die Steuerung in diesem Bereich zwischen lock/unlock verlangsamt / hängen bleibt.

Hat Jemand eine Idee, wie ich absichtlich diese Datei beschädigen kann um das ganze zu simulieren?

Gruß
Thorsten
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1374
Registered: 03 / 2005
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 26.07.2022 - 11:46  ·  #13
I did something similar a few years ago. I was aware that the SD card could be removed at any time so I used the build in switch and separately monitored it to see both if a card was present but also if it had been removed/replaced. I wonder if that is a possibility for you?

Like you I opened and closed the file each time, but if the card had been removed I totally restarted the file system.

Certainly for me it was totally robust, but one major difference is that I have always used co-operative mutlitasking rather than the built in pre-emptive multitasking so lock/unlock did not apply to my application.

Regards

Merlin.
pvs-deck
PowerUser
Avatar
Gender:
Age: 53
Homepage: pvs-deck.de
Posts: 1341
Registered: 02 / 2009
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 26.07.2022 - 12:47  ·  #14
Hello Merlin,

yes, I have a switch. When this comes new, the FileSystem is restarted. Also when unplugging the card I stop the function with "F16_FlushBufSec" / "F16_FileClose".

I need to test how much time I have when pulling the card, between the contact for removing the card and the final disconnect of the card.

It can come with the push system quite quickly shot out of the holder, just when you slip after pressing, then the card shoots out of the holder.

Thorsten
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1374
Registered: 03 / 2005
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 26.07.2022 - 13:09  ·  #15
Yes but F16_FileClose cannot work under these circumstances. I am not sure about F16_FlushBuffSec but I suspect that can't work either.

Regards

Merlin.
pvs-deck
PowerUser
Avatar
Gender:
Age: 53
Homepage: pvs-deck.de
Posts: 1341
Registered: 02 / 2009
Subject:

Re: Task/Process hängt sich scheinbar auf.

 · 
Posted: 02.08.2022 - 21:43  ·  #16
Hallo Merlin,

ich habe Heute eine der Problemsteuerungen von meinen Kunden erhalten. So wie es aussieht hängt sich die Steuerung beim schreiben der Logdatei auf.

Als erstes ist mir aufgefallen, das hier verschiedene Einträge auf der SD-Card erstellt wurden (Bild 1), diese Speicherkarte wurde wohl in einem Windows PC eingesteckt "LOST.DIR" und in einem Androidgerät eingesteckt "Android" Ordner.

Kann es sein, das hier mit diesen langen Dateinamen ein Problem mit dem F16 Funktionen gibt?

Die Logbuchdatei auf der Steuerung hat verschiedene Fehlerhafte Einträge (Bild 2).
Aber wenn ich diese Datei einfach auf eine neue SD-Karte kopiere (ohne die Android und LOST.DIR Ordner) schreibt meine Steuerung einfach an der Datei weiter.

Gruß
Thorsten

-----------------------------------------------------
Hello Merlin,

I received one of the problem controllers from my customers today. It looks like the controller hangs when writing the log file.

The first thing I noticed is that here are different entries on the SD card were created (Figure 1), this memory card was probably inserted in a Windows PC "LOST.DIR" and inserted in an Android device "Android" folder.

Is it possible that there is a problem with the F16 functions with these long file names?

The logbook file on the controller has several erroneous entries (picture 2).
But if I simply copy this file to a new SD card (without the Android and LOST.DIR folders) my controller just keeps writing to the file.

Greetings
Thorsten
Attachments
Bild1
Filename: Bild1.png
Filesize: 41.07 KB
Title: Bild1
Information: Bild1
Download counter: 39
Bild2
Filename: Bild2.png
Filesize: 28.07 KB
Title: Bild2
Information: Bild2
Download counter: 38
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Page 2 of 6
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 9 · Cache Hits: 15   140   155 · Page-Gen-Time: 0.01623s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI