mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-13 20:50:19 +01:00
deviceinfo: convert Linux priority to a value between 0 and 99
This commit is contained in:
parent
18643f29b3
commit
38e1aef3af
2 changed files with 11 additions and 0 deletions
|
|
@ -170,7 +170,17 @@ int os__get_process_size(char* refparam, struct dmctx *ctx, void *data, char *in
|
|||
/*#Device.DeviceInfo.ProcessStatus.Process.{i}.Priority!UBUS:router.system/processes//processes[@i-1].priority*/
|
||||
int os__get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
int priority = 0;
|
||||
|
||||
*value = dmjson_get_value((json_object *)data, 1, "priority");
|
||||
|
||||
priority = (*value && **value) ? atoi(*value) : 0;
|
||||
|
||||
/* Convert Linux priority to a value between 0 and 99 */
|
||||
priority = round((priority + 100) * 99 / 139);
|
||||
|
||||
dmasprintf(value, "%d", priority);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include <getopt.h>
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue