Linux-Development-Sys Digest #743, Volume #8     Wed, 23 May 01 12:13:13 EDT

Contents:
  Re: fork, pthread_create and the FP stack (Kasper Dupont)
  dd reminder ("Brad Hubbard")
  Re: dd reminder (Rolf Magnus)
  Re: dd reminder ("Brad Hubbard")
  Re: dd reminder ("Zoran Cutura")
  Re: Trouble using large amount of memory with Redhat 7 ("Karl Heyes")
  Re: Writing a SystemCall (Kasper Dupont)
  question about fork() (Wong Ka Chun)
  Re: question about fork() (Sascha Bohnenkamp)
  Re: question about fork() (Kasper Dupont)
  Self Installing CD ("Wayne")
  Re: looking for simple sleep func. in kernel (Kasper Dupont)
  Re: Self Installing CD (Kasper Dupont)
  Re: Win NT boot and Lilo boot (Kasper Dupont)
  Re: dd reminder (Johan Kullstam)
  Re: A TCP-oriented filesystem???  (At150bogomips)
  Re: question about fork() (Wong Ka Chun)
  preventing process group changes ("Robert A. Knop Jr.")
  Re: dd reminder ("Karl Heyes")

----------------------------------------------------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: fork, pthread_create and the FP stack
Date: Wed, 23 May 2001 08:14:58 +0000

Dale Johnson wrote:
> 
> What happens to the values in the Intel FP stack when
> a fork occurs?  Does the new process inherit the same
> values?  Is this different than the behaviour on a
> pthread_create?
> 
> Also, when a page fault happens, does it push the FP
> values onto a process context area?
> 
> Dale.

There is space in the task_struct for the FP registers.
The registers are only saved to this space when it for
some reason is necesarry.

The fork() syscall will copy the entire task_struct
which includes the saved FP registers, I think the FP
registers are saved to the task_struct before this
happens, but I have not studied that part of the code.

If a page fault is triggered by some of the kernel
mechanisms like CoW pages or swap pages it is supposed
to be transparent to the runing process. It might not
be necesarry to save FP registers every time this
happens, but if loading a page from swap makes the
system switch from one process using the FP to another
process using the FP it is necesarry to save the FP
registers.

-- 
Kasper Dupont

------------------------------

Reply-To: "Brad Hubbard" <[EMAIL PROTECTED]>
From: "Brad Hubbard" <[EMAIL PROTECTED]>
Subject: dd reminder
Date: Wed, 23 May 2001 08:43:17 GMT

Can someone confirm this is appropriate to copy one partition to another?

dd if=/dev/hda1 of=/dev/md1 bs=1



--
Brad Hubbard
Congo Systems
12 Northgate Drive,
Thomastown, Victoria, Australia 3074
Email: [EMAIL PROTECTED]
Ph: +61-3-94645981
Fax: +61-3-94645982
Mob: +61-419107559





------------------------------

From: Rolf Magnus <[EMAIL PROTECTED]>
Subject: Re: dd reminder
Date: Wed, 23 May 2001 10:47:07 +0200

Brad Hubbard wrote:

> Can someone confirm this is appropriate to copy one partition to another?
> 
> dd if=/dev/hda1 of=/dev/md1 bs=1

I would not use bs=1, but if /dev/hda1 is the input and /dev/md1 is the 
output, it should work.

------------------------------

Reply-To: "Brad Hubbard" <[EMAIL PROTECTED]>
From: "Brad Hubbard" <[EMAIL PROTECTED]>
Subject: Re: dd reminder
Date: Wed, 23 May 2001 08:54:30 GMT


"Rolf Magnus" <[EMAIL PROTECTED]> wrote in message
news:9eftd0$7v5$[EMAIL PROTECTED]...

> I would not use bs=1, but if /dev/hda1 is the input and /dev/md1 is the
> output, it should work.

What block size would you use?

Thanks for the reply BTW.

Brad



------------------------------

From: "Zoran Cutura" <[EMAIL PROTECTED]>
Subject: Re: dd reminder
Date: Wed, 23 May 2001 11:08:32 +0200
Reply-To: [EMAIL PROTECTED]

Once upon a while "Brad Hubbard" <[EMAIL PROTECTED]> wrote:

> "Rolf Magnus" <[EMAIL PROTECTED]> wrote in message
> news:9eftd0$7v5$[EMAIL PROTECTED]...
> 
>> I would not use bs=1, but if /dev/hda1 is the input and
>> /dev/md1 is the output, it should work.
> 
> What block size would you use?
> 

A block size of the same size as inode size on the partitions
filesystem is probably apropriate, but it isn't to important.
Use the default block size. A block size of 1 would force dd
to read 1 byte and write 1 byte, which would slow down
unnecessarily.

-- 
Z ([EMAIL PROTECTED])
"LISP  is worth learning for  the profound enlightenment  experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days."   -- Eric S. Raymond

------------------------------

From: "Karl Heyes" <[EMAIL PROTECTED]>
Subject: Re: Trouble using large amount of memory with Redhat 7
Date: Wed, 23 May 2001 13:12:11 +0100

In article <9efbji$kd9$[EMAIL PROTECTED]>, "J. P. Montgomery"
<[EMAIL PROTECTED]> wrote:


> Thanks for the added information ... I did run strace and appear to be using
> the latest libraries ... I'll bring the files home tomorrow and send them if
> necessary.  Incidently, although I have used mem= in lilo but have not
> included it presently.  I'll try this tomorrow.  Is there anything in the
> strace output you were looking for other than the libraries?  I noticed that
> it was outputting bk() values that I have seen in memory discussions ...
> Incidently, I use Portland compilers ... I have only mentioned g77 as a way
> of comparing results.  The Portland guy I exchanged email said that g77
> imposes a hard limit on size ... but I still find this hard to believe since
> I know a lot of people regularly use gcc and g77. 

brk is the actual call used by the libraries to allocate more space from the
process VM.   Does g77 require many libraries, not knowing g77 means I'm not
sure of it's memory usage.

> Portland is licensed
> software ... but allows a home use license and so both compilers are
> identical versions running the same kernel (except the SMP kernel is used at
> home on the dual processor machine).
> I understand about swap and ram ... I do not understand the actual limits in
> the kernel and how to find them.  When I use a simple C code to retrieve the
> resource limits (rlimit) I get 4G for the process size (ram+swap).  However,
> I had not run this on the big machine with the SMP kernel.  I would have
> thought that this would have retrieved the values that the kernel
> recognizes.

2 Gig is the default for a user process,  but that gets used for program,
libraries and it's data, so it depends on the program and how efficient the
libraries are at allocating memory.

> I was wondering what you think about just upgrading my distribution to
> Redhat 7.1 and the 2.4.? kernel ... ?  Of course, I do have a never give up
> philosophy ...

or upgrade your kernel to 2.2.19.  I still think the problem is application
related. mail me the strace output, I'll have a quick look.

karl.

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: Writing a SystemCall
Date: Wed, 23 May 2001 12:19:08 +0000

Frank wrote:
> 
> Hi,
> 
> I'm having trouble compiling a system call.  I was wondering if anyone
> could figure out what am I doing wrong.  So, here are all the steps:
> 
> 1) write a function called processinfo.c
> 
> #include <linux/kernel.h>
> #include <linux/sched.h>
> #include <asm/current.h>
> #include <asm/uaccess.h>
> 
> asmlinkage void sys_getProcessInfo(int *pid, int *uid, int *groupid, int
> *start_time)
> {
>         copy_to_user(pid, &current->pid, sizeof(current->pid));
>         copy_to_user(groupid, &current->gid, sizeof(current->gid));
>         copy_to_user(uid, &current->uid, sizeof(current->uid));
>         copy_to_user(pid, &current->start_time, sizeof(current->start_time));
>         return;
> }
> 
> 2) Then, I copied this file to the /usr/src/linux/kernel directory.
> 3) Then, I go to a terminal window and went into superuser mode and
> typed this commandline:
> gcc -O0 -g3 -Wall -c processinfo.c
> 
> 4) At this point, I'm getting a lot of parse and referencing errors.
> 
> So, from the steps above, what did I forget to do?  Am I supposed to
> write to generate the stub(s) first before I write the functions?
> 
> Frank
> TIA

You are taking a completely wrong approach to writing
your kernel code. Adding a system call is a very
complex process. The right way to do it involves
registration of an official syscall number, changing
2-3 kernel files and changing glibc.

Instead I suggest that instead you try writing a kernel
module that register a misc device and use an ioctl to
get the information.

The reason for the compile time errors is that you
compile the code as userspace code, not as kernel code.
You either have to specify -D__KERNEL__ on the command
line when compiling, or insert the following lines in
your .c file, before the includes:
#ifndef __KERNEL__
#define __KERNEL__
#endif

In your particular case that would allow the code to
be compiled, but there are still some things to do to
actually be able to load it.

-- 
Kasper Dupont

------------------------------

From: Wong Ka Chun <[EMAIL PROTECTED]>
Subject: question about fork()
Date: 23 May 2001 12:07:15 GMT

Hi, let say:

main()
{
  char *s = malloc(100000);
  pid child;

  child = fork();
  if (child == 0) {
    execv(/* some program */)
    exit(127);
  }
  if (child != -1)
    waitpid(child...);
  free(s);
}

when the child is created, does it have a copy of 's'? Once it executes
another program, where does s go? How s is recliamined?

I am quite confused with this and hope someone can help me out.

TIA

-- Wong

------------------------------

From: Sascha Bohnenkamp <[EMAIL PROTECTED]>
Subject: Re: question about fork()
Date: Wed, 23 May 2001 14:57:44 +0200

Wong Ka Chun wrote:
> main()
> {
>   char *s = malloc(100000);
>   pid child;
> 
>   child = fork();
>   if (child == 0) {
>     execv(/* some program */)
>     exit(127);
>   }
>   if (child != -1)
>     waitpid(child...);
>   free(s);
> }
> 
> when the child is created, does it have a copy of 's'?
well yes .. a copy of the variable s and the memory it points to
(I know its copy on demand)

> Once it executes
> another program, where does s go?
s? gone, the memory is inherited

> How s is recliamined?
not .. well after the process stops execution

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: question about fork()
Date: Wed, 23 May 2001 13:12:08 +0000

Wong Ka Chun wrote:
> 
> Hi, let say:
> 
> main()
> {
>   char *s = malloc(100000);
>   pid child;
> 
>   child = fork();
>   if (child == 0) {
>     execv(/* some program */)
>     exit(127);
>   }
>   if (child != -1)
>     waitpid(child...);
>   free(s);
> }
> 
> when the child is created, does it have a copy of 's'? Once it executes
> another program, where does s go? How s is recliamined?
> 
> I am quite confused with this and hope someone can help me out.
> 
> TIA
> 
> -- Wong

The fork() system call will copy the buffer allocated
with the malloc() call, so parent and child will each
have a copy they can modify independent.

The execv() system call will free the childs copy of
the buffer if it suceeds. In case execv fails it will
not free the buffer, but it will be freed by the
immediately following exit() system call.

The parents copy of the buffer will be freed by the
free() call. There is no need to wait for the child
to terminate because the child will have its own copy.
You may be able to save memory and time by freeing it
before waiting for the child. The reason freeing the
memory before waiting might even be faster is that the
copy of s is made using CoW pages where the pages are
not copied before needed. By freeing the buffer
immediately it might not be necesarry to copy as many
pages.

-- 
Kasper Dupont

------------------------------

From: "Wayne" <[EMAIL PROTECTED]>
Subject: Self Installing CD
Date: Wed, 23 May 2001 08:13:15 -0500

I'm tring to have CD that formats and self installs some stuff for me...
everything seems to go well until I try to install LILO.  After formatting
the HD I mount it and install my files and all the nessesary files.  LILO
gives me a something about this device not having a valid LILO signature.
There is only 1 HD..  hda.... what am i doing wrong?



------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: looking for simple sleep func. in kernel
Date: Wed, 23 May 2001 13:22:10 +0000

NortonNg wrote:
> 
> hi all,
> 
>     I try to slower my PC to evaluate network performance. For some reason,
> i can't use NIST evaluation. I try to modify the sch_tbf.c to achieve my
> requirment. I try to delay the kernel processing by sleep kernel for some
> micro second. but, which kernel function i should use??
> can anyone show me a simple one?
> 
> Regards,
> jkng

You can use the udelay() function to busywait
for some number of microseconds.

If you don't want to busywait you may sleep
and use a timer to wake you up. But the timer
to wake you up usually does not have
microsecond resolution. (On some architectures
it doesn't even have millisecond resolution.)

-- 
Kasper Dupont

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: Self Installing CD
Date: Wed, 23 May 2001 13:35:47 +0000

Wayne wrote:
> 
> I'm tring to have CD that formats and self installs some stuff for me...
> everything seems to go well until I try to install LILO.  After formatting
> the HD I mount it and install my files and all the nessesary files.  LILO
> gives me a something about this device not having a valid LILO signature.
> There is only 1 HD..  hda.... what am i doing wrong?

It is not very clear from your description what you
are actually doing. My best guess is that you have
forgotten to give a -r option to lilo. You have to
run lilo with a command line similar to this:
   lilo -r /mnt/sysimage
where /mnt/sysimage must be replaced with whatever
mount point you use for your harddisk.

If you will tell us how you partition your harddisk,
how you mount the partitions, and how your
/etc/lilo.conf looks we will be able to help you
much better.

-- 
Kasper Dupont

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: Win NT boot and Lilo boot
Date: Wed, 23 May 2001 13:54:41 +0000

Hugin wrote:
> 
> Hello,
> 
> I've got a Win2000 install on a 90GB Raid array on a Promise
> FastTrak100 controller. To boot of this I have to set my BIOS to
> boot SCSI first. I also have a linux install on a 9GB harddisk
> connected as secondary master. To boot of this I have to set
> the BIOS to boot C first.
> 
> Is there a way (either by using Lilo or NT loader) so that I can
> choose which OS to use during boot?
> 
> The problem is that Lilo can't see the raid array, as it is not supported
> under Linux. Also tried to add a line to boot.ini and created a
> bootsect.lnx file on the raid array which points to the linux unstall,
> but had no luck so far...
> 
> Suggestions?
> 
> Thanks!

Do you know how the BIOS assigns driver numbers to
the drives in the two cases?

Usually the boot device is assigned number 0x80,
and I would expect the other drive to be assigned
0x81. Do you know if your BIOS actually does this.

I don't know the NT loader, so I cannot help you
with that, but I have an idea to how it might be
posible to get it working using LILO.

In some way copy the first few (logical) cylinders
of the SCSI drive to a file. If you cannot do this
from within w2k try some dos utility.

Copy this file to your Linux partition, if you
cannot do this directly you might get it working
by copying it to a floppy first.

Now tell LILO that this file is actually BIOS
device number 0x81, I don't know if LILO will
believe this perhaps it will help to connect it
to a loopback device using the losetup command.

Maybee in this way it will be possible for LILO
to install a map that will actually be able to
boot your w2k disk.

I don't know how much of your SCSI disk will be
needed in the file. Perhaps 512 bytes is enough,
perhaps you need 32KB or maybee a lot more. This
is just an idea, I've never tried anything like
this.

-- 
Kasper Dupont

------------------------------

Subject: Re: dd reminder
From: Johan Kullstam <[EMAIL PROTECTED]>
Date: 23 May 2001 10:46:56 -0400

"Brad Hubbard" <[EMAIL PROTECTED]> writes:

> Can someone confirm this is appropriate to copy one partition to another?
> 
> dd if=/dev/hda1 of=/dev/md1 bs=1

i usually put down a fresh filesystem on the new partition and
then use "cp -ax".

-- 
J o h a n  K u l l s t a m
[[EMAIL PROTECTED]]
sysengr

------------------------------

From: [EMAIL PROTECTED] (At150bogomips)
Date: 23 May 2001 15:05:27 GMT
Subject: Re: A TCP-oriented filesystem??? 

Todd Knarr <[EMAIL PROTECTED]> wrote:
>2) You'd need to severely limit the packet size, probably to less than
>   the 512-byte block size of most disks. You need to accomodate systems
>   that don't allow for transmitting IP packets longer than the minimum.

I thought (ignorant me) that TCP packet size was not so limited.  (In theory,
one can send multiple hardware and/or IP packets containing a single TCP
packet.  Admittedly, one would want a whole number of IP packets per TCP packet
to ease retransmission on non-acknowledgement.)

>3) Pre-calculating checksums works only for the leading portion of the
>   block, because the checksum results are usually dependent not only on
>   the bytes but their order. The data portion of a TCP segment is the
>   last thing in the block, and you need to calculate the checksum on
>   the header fields before you can calculate the data portion.

Again, ignorant me, I thought the checksum was a simple XOR of the 16-bit
chunks.  While different placing of the data might require the two bytes of
such a partal checksum to be flipped, this would be cheaper than a full
recalculation.

>1) The data would still have to be transferred to memory. The NIC can do
>   do DMA from memory, but it can't read directly from the disk.

The idea was to avoid the burden of pushing the data up the CPU memory well. 
(Although one could mark the data as non-cacheable to avoid cache corruption,
normally one still must load all the way from main memory.)  Disk--> RAM-->NIC
only involves two memory accesses; Disk-->RAM-->CPU-->RAM-->NIC involves four
memory accesses.  It just seemed that two accesses would be faster/less
burdensome than four accesses.

Paul A. Clayton
just a fool, not in love

------------------------------

From: Wong Ka Chun <[EMAIL PROTECTED]>
Subject: Re: question about fork()
Date: 23 May 2001 15:00:07 GMT

Hi Kasper,

  I see. So when child exit, the system will recliam all the memory. However, I have 
further question on this. Say, if the fork and wait things are done in a
thread, will there be any problem? Also, if the parent contain C++ object and link 
with some other shared libaries, will the destructor be called? Will the .fini() 
function be called in the shared libraries when child terminates?

TIA.

- Wong



Kasper Dupont <[EMAIL PROTECTED]> wrote:
: Wong Ka Chun wrote:
:> 
:> Hi, let say:
:> 
:> main()
:> {
:>   char *s = malloc(100000);
:>   pid child;
:> 
:>   child = fork();
:>   if (child == 0) {
:>     execv(/* some program */)
:>     exit(127);
:>   }
:>   if (child != -1)
:>     waitpid(child...);
:>   free(s);
:> }
:> 
:> when the child is created, does it have a copy of 's'? Once it executes
:> another program, where does s go? How s is recliamined?
:> 
:> I am quite confused with this and hope someone can help me out.
:> 
:> TIA
:> 
:> -- Wong

: The fork() system call will copy the buffer allocated
: with the malloc() call, so parent and child will each
: have a copy they can modify independent.

: The execv() system call will free the childs copy of
: the buffer if it suceeds. In case execv fails it will
: not free the buffer, but it will be freed by the
: immediately following exit() system call.

: The parents copy of the buffer will be freed by the
: free() call. There is no need to wait for the child
: to terminate because the child will have its own copy.
: You may be able to save memory and time by freeing it
: before waiting for the child. The reason freeing the
: memory before waiting might even be faster is that the
: copy of s is made using CoW pages where the pages are
: not copied before needed. By freeing the buffer
: immediately it might not be necesarry to copy as many
: pages.

: -- 
: Kasper Dupont

------------------------------

From: "Robert A. Knop Jr." <[EMAIL PROTECTED]>
Subject: preventing process group changes
Date: Wed, 23 May 2001 08:36:20 -0700

I want to start a process as root, change it's process group, have it
start some child processes as another UID, and then prevent the child
processes from in turn changing their process group.  Is this possible?
How does one go about doing this?

I can think of two ways it might work.  One might be to prevent any UID
but root from running setpgrp.  The second is a concept I've seen
mentioned in passing, but haven't been able to find out how one goes
about actually doing it.  That is locking a process and its progeny into
a given process group.  Does Linux support this concept at all?

Thank you,

-Rob Knop
[EMAIL PROTECTED]

------------------------------

From: "Karl Heyes" <[EMAIL PROTECTED]>
Subject: Re: dd reminder
Date: Wed, 23 May 2001 17:01:56 +0100

In article <[EMAIL PROTECTED]>, "Johan Kullstam"
<[EMAIL PROTECTED]> wrote:


> "Brad Hubbard" <[EMAIL PROTECTED]> writes:
>> Can someone confirm this is appropriate to copy one partition to another? 
>> dd if=/dev/hda1 of=/dev/md1 bs=1
> i usually put down a fresh filesystem on the new partition and then use "cp
> -ax".
> 

I would agree that dd probably isn't the best tool here due to possible
differences in partition size.  Personally I use tar.

karl.

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.system newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-System Digest
******************************

Reply via email to