From: sena <auntvini@sedal.usyd.edu.au>
To: holt@sgi.com
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: uid-task_struct Code after Proper Naming and indentation
Date: Wed, 07 Jan 2004 05:04:28 +1100 [thread overview]
Message-ID: <3FFAF8AC.5040307@sedal.usyd.edu.au> (raw)
Hi Robin,
ps way of reading uid is good.
Though they are in 2 differant modes (kernel and user)
Will that be a problem?
Herewith I am sending to you the code after proper indentation.
In timer.c file I have included and then updated all the neccessary
functions else where accordingly.
unsigned long numof_root_tasks; //for root uid<500, I am getting this
uidArray[0] is for storing uid (assumed 100 for all <500)
unsigned long numof_uid500_tasks; //for 500
unsigned long numof_uid501_tasks; //for 501
unsigned long numof_uid502_tasks; //for 502
unsigned long numof_uid503_tasks; //for 503
unsigned long numof_uid504_tasks; // for 504
unsigned int uidArray[7];
static unsigned long
count_active_tasks(void)
{
struct task_struct *p;
unsigned long nr = 0;
int s = 0;
int i = 0;
int j = 0;
int k = 0;
int m = 0;
read_lock(&tasklist_lock);
for_each_task(p) {
if ((p->state == TASK_RUNNING ||
(p->state & TASK_UNINTERRUPTIBLE))) {
nr += FIXED_1; //nr total tasks
if (i == 0) {
uidArray[0] = 100;
if (p->uid < 500) {
numof_root_tasks += FIXED_1;
} else {
uidArray[1] = p->uid;
numof_uid500_tasks += FIXED_1;
k++;
}
k++;
} else {
for (j = 0; j < k; j++) {
if ((j == 0) && (p->uid < 500)
&& (s == 0)) {
numof_root_tasks +=
FIXED_1;
s = 1;
break;
} else if ((uidArray[j] == p->uid)
&& s == 0) {
if (j == 1) {
numof_uid500_tasks
+= FIXED_1;
}
if (j == 2) {
numof_uid501_tasks
+= FIXED_1;
}
if (j == 3) {
numof_uid502_tasks
+= FIXED_1;
}
if (j == 4) {
numof_uid503_tasks
+= FIXED_1;
}
if (j == 5) {
numof_uid504_tasks
+= FIXED_1;
}
s = 1;
break;
}
}
if (s == 0) {
if (k < 6) {
k++;
j = k - 1;
uidArray[j] = p->uid;
if (j == 1) {
numof_uid500_tasks
+= FIXED_1;
}
if (j == 2) {
numof_uid501_tasks
+= FIXED_1;
}
if (j == 3) {
numof_uid502_tasks
+= FIXED_1;
}
if (j == 4) {
numof_uid503_tasks
+= FIXED_1;
}
if (j == 5) {
numof_uid504_tasks
+= FIXED_1;
}
}
}
s = 0;
}
i++;
}
}
read_unlock(&tasklist_lock);
return nr;
}
unsigned long avenrun[6];
unsigned long avenrunT;
static inline void
calc_load(unsigned long ticks)
{
unsigned long active_tasks; /*fixed-point */
static int count = LOAD_FREQ;
count -= ticks;
if (count < 0) {
count += LOAD_FREQ;
active_tasks = count_active_tasks();
CALC_LOAD(avenrunT, EXP_5, active_tasks);
CALC_LOAD(avenrun[0], EXP_5, numof_root_tasks);
CALC_LOAD(avenrun[1], EXP_5, numof_uid500_tasks);
CALC_LOAD(avenrun[2], EXP_5, numof_uid501_tasks);
CALC_LOAD(avenrun[3], EXP_5, numof_uid502_tasks);
CALC_LOAD(avenrun[4], EXP_5, numof_uid503_tasks);
CALC_LOAD(avenrun[5], EXP_5, numof_uid504_tasks);
}
}
Thanks
Sena Seneviratene
Computer Engineering Lab
Sydney University
next reply other threads:[~2004-01-07 6:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-06 18:04 sena [this message]
2004-01-07 17:12 ` Robin Holt
2004-01-07 3:42 ` auntvini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3FFAF8AC.5040307@sedal.usyd.edu.au \
--to=auntvini@sedal.usyd.edu.au \
--cc=holt@sgi.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome