繁体   English   中英

我可以在树莓派上同时运行多少个py脚本?

[英]How many py script can I run on raspberry pi simultaniously?

我知道您可以使用不同的终端运行多个脚本,但是必须有一个限制。 我不能只在一个小圆周上跑一百万。 所以真正的问题是...有没有办法检查我的脚本的要求。 先感谢您!

pi零瓦特/ python 3

忽略由于内存和CPU消耗而导致的明显限制,如果您在Raspberry PI上运行基于Linux的操作系统,则可以检查/proc/sys/kernel/pid_max 手册页

/proc/sys/kernel/pid_max (since Linux 2.5.34)
          This file specifies the value at which PIDs wrap around (i.e.,
          the value in this file is one greater than the maximum PID).
          PIDs greater than this value are not allocated; thus, the
          value in this file also acts as a system-wide limit on the
          total number of processes and threads.  The default value for
          this file, 32768, results in the same range of PIDs as on ear‐
          lier kernels.  On 32-bit platforms, 32768 is the maximum value
          for pid_max.  On 64-bit systems, pid_max can be set to any
          value up to 2^22 (PID_MAX_LIMIT, approximately 4 million).

换句话说:在大多数默认配置下,Linux最多可以同时运行32,768个进程(和线程,合计)。 请注意,您正在与系统上运行的所有其他功能(包括操作系统本身的某些部分)共享这些PID。

因此,假设您默认情况下有150个进程和线程正在运行,并且脚本使用的CPU和内存量可以忽略不计,并且仅使用一个线程,那么您最多可以同时运行32,618个脚本实例。

没有明确的固定限制。 就像台式机或笔记本电脑一样,限制取决于每个正在运行的程序占用多少资源。 就像您的计算机一样,消耗太多资源的结果可能会有所不同。 这可能导致程序运行速度变慢或完全崩溃。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM