Linux / Unix

Obtain a list of process scheduling policy and priority

Normally, you can read the file /proc/[pid]/sched and get the related information. But since I am using a simplified one, the sched file is not presented. And I need to figure out another way to get it. I finally found there is a C library, <sched.h>, to do that. You can find the following declarations in the library.

In this case, we only need sched_getparam() to obtain scheduling priority and sched_getscheduler() to obtain scheduling policy.

How to get the number / id of processes and threads?

Since I am working on Hi3518 with Linux, in order to reduce the use of computing power of the device, I used a simplified version of Linux. So, most of the applications are gone or are simplified without any option. I just summarized the methods I can use on Hi3518 and should be also work on some other Embedded Linux.

In fact, the applications in Linux usually obtain related information by reading the files in /proc. Under /proc, you can see a lot of folder, some of them are in numbers. Those folders named in numbers, which are process ids (PIDs) represent the processes run in the system. Thus, you can see the details of each process in each folder.


where *** are the corresponding process pid.

Embedded Linux: 如何讓海思Hi3518開機後自動執行Shell Script?


已經了解了Hi3518一段時間,目前需要它於開機啟動時自動插入一些驅動和程序,所以小小研究了一下要怎麼做。首先,因為有一系列的指令要做,所以就給它寫了個Shell Script(腳本),讓它可以一次過運行我所有的指令,之後再放入Startup。至於Shell Script要怎麼寫,我暫時就不多說了,因為我知的也不多~ 哈哈~

0. 基礎知識

/etc/init.d/ : init.d 是一個用來存放Unix/Linux Shell Script的文件夾,如果你的內核有開啟 init.d 的話,系統啟動時,會在登入前自行執行存放在這裡的腳本。一般系統上所有服務的啟動腳本都會放在這裡,一般是Linux系統的話,應該都會看到它的蹤影。