stop and start thread with tcl

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf stop and start thread with tcl

  • Creator
    Topic
  • #50107
    Gary Atkinson
    Participant

    How do you get the process and thread name from within a tcl proc?  I want to modify the resend recovery proc so that if after “3” resends, to stop and start the thread; then proto the $ob_save.

Viewing 6 reply threads
  • Author
    Replies
    • #64921
      Robert Milfajt
      Participant

      The thread name is in the HciConnName variable, which you need to make global at the beginning of your proc:

      Code:

      global HciConnName

      The process name I am not sure of, but we have a TCL proc we wrote in which if given the thread name returns its process name.  There may be something easier for this, but this works.

      Code:

      ######################################################################
      # get_pname – get the process name that contains the specified thread
      #
      # Args: thread  = the thread name
      #
      # Returns: process      = the process that contains the specified thd
      #
      proc get_pname { thread } {
             set conndata [exec hciconndump $thread]
             set lines [split $conndata n]
             set thdinfo [lindex $lines 3]
             set pname [lindex $thdinfo 0]
             if {”$pname” == “”} {error “Thread not found: $thread”}
             return $pname
      }

      Hope this helps,

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #64922
      Charlie Bursell
      Participant

      Boy Bob, a lot of work for a simple problem  😀

      set processName [file tail [pwd]]

      Simple

    • #64923
      Gary Atkinson
      Participant

      I am curious to know how the code

      Code:

      set processName [file tail [pwd]]


      works inside the engine.

      When using a tcl proc in a thread the directory is ./process directory?

    • #64924
      Charlie Bursell
      Participant

      pwd is current directory.  The file tail command returns the last component of the path.  Since a Cloverleaf engine always runs in the process directory which is the sma name of the process, you have the process name

    • #64925
      Robert Milfajt
      Participant

      I am going to have to say it was not my code!   😀

      Thanks for the tip Charlie, I smell a rewrite coming on…

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #64926
      Chris Williams
      Participant

      And if you are outside the specific process directory and need to know what process contains a particular thread, you can pull it from NetConfig:

      Code:


      proc getProcessForThread {threadName} {
         set pname {}
         set netconfig [file join $HciSiteDir NetConfig]
         nfLoad $netconfig processData hostData xlateData NetFilePrologue
         set kl [lindex [array get hostData [string tolower $threadName]] 1]
         keylget kl PROCESSNAME pname
         return $pname
      }

    • #64927
      Bob Richardson
      Participant

      Folks,

      Just a caveat on nfLoad here:  it converts thread and process names to all lower case.  So if your shop folllows standard naming conventions (gulp!)

      and creates threads/processes in lower case, not mixed or upper nfLoad

      will work here.

      Enjoy.

Viewing 6 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
4,966
Forums
28
Topics
9,104
Replies
33,618
Topic Tags
248