proceses selection
- From: "klaic" <mklaic_remove_@xxxxxxxx>
- Date: Sun, 27 Nov 2005 21:41:45 +0100
I have a problem with writing a function which puts proceses in a list. I
have to select only those elements which have priority greater than other
brother proceses.
Brother proceses are those which have same parent proces ID (PPID).
Proceses from which I need to make selection look like this:
proceses.txt
PID UID PPID GID Priority Status
1 5 0 0 1 0
2 6 1 1 2 0
3 7 6 1 7 0
4 7 3 1 7 0
5 7 3 4 7 0
6 7 4 3 6 0
7 7 4 5 6 0
8 7 4 0 6 0
9 7 4 0 6 0
10 7 4 0 5 0
11 7 4 0 5 0
12 7 4 0 5 0
PID - proces ID
PPID -parent proces ID
GID - group ID
UID -user ID
I have written somethin like this (it doesn't work like i would like):
[CODE]
struct proces *NewList(struct proces *start) // function gets start of
list
{
struct proces *p, *r, *newList = NULL; //pointers to list elements
int bigest_priority;
p = start; //pointer to start element
while(p){
r = start;
while(r){
if(p->PPID == r->PPID && p != r){ // brothers ??
if(r->priority > p->priority){ // priority ??
bigest_priority = r->priority;
}
else{
bigest_priority = p->priority;
}
}
else{
if(p != r)
p = r;
}
r = r->next;
}
r = start;
while(r){
if((r->PPID == p->PPID) && (r->pririty >= bigest_priority)){
AddToNewList(&newList, r);
}
r = r->next;
}
p = p->next;
}
return newList;
}
[/CODE]
Any ideas?
.
- Prev by Date: Re: VB or VC++?
- Next by Date: Re: Write to unused memory-mapped IO address (0xfffffffc)
- Previous by thread: Write to unused memory-mapped IO address (0xfffffffc)
- Next by thread: How to append data in an existing buffer (in C language)
- Index(es):