public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Heather Peterson <hpeterson@intldata•ca>
To: linuxppc-embedded@lists•linuxppc.org
Subject: linuxrc thread doesn't terminate
Date: Mon, 03 Dec 2001 15:52:34 -0500	[thread overview]
Message-ID: <3C0BE612.51F79C59@intldata.ca> (raw)


Hi,

I'm relatively new to linux.  I hope this isn't a repeat
question, but I tried searching through the old postings
and couldn't find an answer.

I'm using an 860P custom board running the 2.2.14 kernel
from HardHat.  I got it working using both NFS and with an
initial ramdisk.  However, now I want to start up with a
small initrd and then mount the real root filesystem off a
compact flash card.

My system is configured with CONFIG_BLK_DEV_INITRD and
my boot argument is root=/dev/cfda2 (my compact flash
device).  My initrd has a linuxrc file that loads the
drivers neccessary to access the compact flash device.

I put print statements in init/main.c

    pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);

    printk("My printk: launched thread to call linuxrc,
            pid = %d\n", pid);

    if (pid>0)
        while (pid != wait(&i));

    printk("\nMy printk: Thread terminated\n");

Here is my linuxrc file:
    #!/bin/sh

    echo 'Loading compact flash drivers.'
    insmod ports.o
    insmod i2c.o
    insmod cfd.o
    echo 'End of linuxrc.'

When it runs I see the first print statement, I see the
output from my linuxrc script, but I never see the second
print statement.  Is the thread not terminating properly?
How can I tell?

I also tried adding a counter to the loop and using waitpid
instead of wait:
    pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
    printk("My printk: launched thread to call linuxrc,
            pid = %d\n", pid);
    rc = 0;
    loopCount = 0;
    if (pid>0)
    {
        printk("My printk: waiting:\n");
        while ((pid != rc) && (loopCount++ < 80000))
        {
            current->policy |= SCHED_YIELD;
            schedule();
            rc = waitpid(pid, &i, WNOHANG);
        }
    }
    if (rc == pid)
        printk("\nMy printk: Thread terminated\n");
    else
        printk("\nMy printk: continuing without
                  termination of linuxrc thread\n");

This seems to work.  My drivers load from the linuxrc
script and then I see the print statement "continuing
without termination of linux rc thread", and it goes on
to call change_root().  Any ideas why wait and waitpid
never return with the pid of the linuxrc thread?  What
am I doing wrong?

Any help would be greatly appreciated.

Thanks,

Heather


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

                 reply	other threads:[~2001-12-03 20:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3C0BE612.51F79C59@intldata.ca \
    --to=hpeterson@intldata$(echo .)ca \
    --cc=linuxppc-embedded@lists$(echo .)linuxppc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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