PS Command
The PS Command displays the current processes. JANOS is a preemptive multi-tasking environment. It can execute up to 16 processes using a simple priority scheme. Each process is given an ID and each new process receives a unique ID. For example:
412dmx_r01 /> ps 0: Idle Process 1: Network Service 2: System 7: Command/Serial 4 total 2:19:16.988 uptime 412dmx_r01 />
The Idle Process (PID 0) collects time when the system has nothing to do; The Network Service (PID 1) handles all network activity on a high priority basis; And, the System Process (PID 2) performs all routine system activities. These 3 processes are created at boot and always appear in the process list. The PS -V
command provides a more verbose output format that contains more information.
412dmx_r01 /> ps -v runtime mem hnd stk frm id desc 2:24:35.303 0: Idle Process 3.991 2.7K 7 11 1: Network Service 11.217 1.3K 7 13 2: System 12.246 37.9K 7 20 7: Command/Serial 4 total 2:25:36.193 uptime 412dmx_r01 />
This displays the runtime accumulated by each process. The Idle Process should accumulate the most runtime. If that is not the case then perhaps there tight loops in an application that could benefit from a Thread.sleep().
This also displays the amount of memory assigned to the process (mem). If this number were to continually grow with subsequent PS -V commands, then the application may have a memory leak. You might be creating an array and never pruning old entries. Or, there could be a JANOS issue that we would very much appreciate you pointing out to us.
The Handle count is displayed (hnd). Handles represent I/O streams such as stdin, stdout, stderr, comin, comout, auxin, and auxout. These are the 7 default streams. If you open a file or a network stream a handle is assigned. An application can have a number of handles however these too should not increase with time. They also can leak if not properly closed.
Each process has its own stack. The percentage of stack usage is displayed (stk). If a stack overflows it s percentage would reach 100. This is not desirable.
JANOS can execute Java programs. A Java Virtual Machine is launched for each program. In those cases the number of stack frames in use is displayed (frm). This number is limited by the amount of memory. It should be fairly stable for any application.
Other processes may appear in the process list. For example:
412dmx_r01 /> ps -v runtime mem hnd stk frm id desc 2:47:44.211 0: Idle Process 4.879 2.7K 7 11 1: Network Service 12.895 1.3K 7 13 2: System 2.939 73.9K 9 20 10: Web Server 16.721 38.3K 7 20 7: Command/Serial 0.057 33.8K 7 12 13: Console/10.0.0.20:13948 0.499 33.8K 7 12 14: Command/10.0.0.20:13981 7 total 2:48:57.353 uptime 412dmx_r01 />
The Web Server is executed to handle connections from browsers. This process is started automatically and remains active for as long as there are valid and active web connections. If there are several minutes of inactivity the Web Server will terminate. It would be restarted should another connection request be received. A single Web Server process handles all web connections.
The Command/Serial process here indicates that I am connected via the RS-232 (COM) port and have an active command line session. Here I must be careful to use the EXIT or BYE command or the process will remain active. Simply disconnecting the cable will not remove this process. There can be only one active serial command line connection.
The Command/[IP Address:Port] process indicates that I have connected to a command line through Telnet (Port 23). This will terminate once that network connection is closed. Each Telnet connection is its own process.
And the Console/[IP Address:Port] process indicates that there is a Console Session open through the DCP (or other Websockets connection). There are multiple ways to access the command line. You can tell them apart by their process name. Each Console Session is its own process.
The Protocol Server may appear as a process. Like the Web Server the Protocol Server handles one or more JNIOR Protocol connections. The service is automatically started when a JNIOR Protocol (Port 9200) connection is requested. After a period of inactivity the Protocol Server will terminate.
The JNIOR Protocol is a deprecated binary protocol which can be used to configure, control and monitor the JNIOR. It is supported however we recommend that new applications use the Websockets Interface. The latter has the same functionality and much more. It is a modern interface.
Unlike the Web Server and Protocol Server each FTP (File Transfer Protocol) connection is its own process. These will appear as FTP/[IP Address:Port].
JANOS can make secure network connections using TLSv1.2. When secure communications are active the Secure Transport process will run. A single Secure Transport process handles all secure communications. It augments network streams belonging to other processes by imposing the TLS protocol and performing the associated encryption and decryption.
The Security Update process is related and is executed when new RSA Keys are being generated. The process of generating a new key pair is computationally intensive. The Security Update process performs that task at a low priority and in the background. JANOS can generate a new set of keys periodically. It then updates its own self-signed certificates. This represents a level of security unprecedented in an embedded controller. The Administrator can install externally generated keys and signed certificates.
Finally each application runs as its own process. Each is a JVM. These will be indicated by program name along with an indication as to how the program was executed. For example.
412dmx_r01 /> ps -v runtime mem hnd stk frm id desc 1.956 0: Idle Process 1.335 1.2K 7 1 1: Network Service 0.062 1.2K 7 15 2: System 1.362 58.6K 7 24 7 3: Run/Dmx.jar 0.020 34.3K 7 12 4: Command/Serial 5 total 4.760 uptime 412dmx_r01 />
here the DMX.jar
program was started through a Registry Run key. Compare with the following where the same program has been started at the command line.
412dmx_r01 /> ps -v runtime mem hnd stk frm id desc 1:51.124 0: Idle Process 1.406 2.7K 7 8 1: Network Service 0.540 1.2K 7 15 2: System 1.210 51.9K 7 24 7 5: Command/Serial/dmx 0.081 34.7K 7 12 4: Command/Serial 5 total 2:24.376 uptime 412dmx_r01 />
Notice in the previous post how the application program has a number of stack frames (frm). These programs are executed by a JVM.