adding proc to allproc
Ferner Cilloniz
fernercc at gmail.com
Sat Dec 20 00:23:26 PST 2008
The process comes from the allproc list.
I am simply iterating through this list and removing the first 1/2 of
allproc list and adding the removed process to my own singly linked
list.
LIST_REMOVE(current_proc, p_list); // remove from the allproc
add_proc_entry(current_proc);
Later, i am iterating through my singly linked list and doing the below:
struct proc *p = current->p;
f( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){
LIST_INSERT_HEAD(&allproc, p, p_list);
}
Could this be causing a circular list?
I am adding the proc entries to my singly linked list as follows:
static void add_proc_entry(const struct proc *p)
{
struct proc_ll *new_entry = (struct proc_ll*)malloc(sizeof(struct
proc_ll), M_TEMP, M_ZERO | M_NOWAIT);
int done = 0;
new_entry->p = p; // maybe doing this assignment isnt correct?
if(proc_entries == NULL) {
proc_entries = new_entry;
return;
}
struct proc_ll *current = proc_entries;
while(current != NULL) {
if(current->next == NULL) {
current->next = new_entry;
break;
}
current = current->next;
}
}
struct proc_ll {
struct proc *p;
struct proc_ll *next;
};
A circular list does sound like it could cause hanging to occur but the
above code, atleast from my eyes, doesn't seem to cause it.
On Fri, 2008-12-19 at 21:39 -0800, Julian Elischer wrote:
> Ferner Cilloniz wrote:
> > When i run the code from a KLD it hangs the system. No reboot occurs
> > however, it just hangs there.
>
> well, firstly you have no locking though that would probably let you
> get away with it most times.
>
> Where does the process come from in the first place?
>
> It sounds like you are making a circular list somewhere or somehow...
>
> have you tried going into ddb?
>
>
>
>
> >
> >
> > On Fri, 2008-12-19 at 21:27 -0800, Julian Elischer wrote:
> >> Ferner Cilloniz wrote:
> >>> Hello everyone.
> >>>
> >>> I am playing with freebsd and just learning some things about the
> >>> FreeBSD kernel.
> >>>
> >>> So for my first quest i am placing random processes from the allproc
> >>> list into a list of my own and trying to add them back into allproc
> >>>
> >>> I have pasted the code below.
> >>>
> >>> -----------------------------------------------------------------------
> >>> struct proc *p = a process from my own list;
> >>> if( p != NULL && (p->p_state == PRS_NEW || p->p_state == PRS_NORMAL) ){
> >>> LIST_INSERT_HEAD(&allproc, p, p_list);
> >>> }
> >>> -----------------------------------------------------------------------
>
> >>
> >>> _______________________________________________
> >>> freebsd-hackers at freebsd.org mailing list
> >>> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> >>> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
More information about the freebsd-hackers
mailing list