Linux-Development-Sys Digest #383, Volume #8     Sun, 31 Dec 00 17:13:18 EST

Contents:
  Re: smp and gcc (Pat Shelton)
  Re: cpu count (Robert Redelmeier)
  Re: redirecting stdin to a memory buffer (Floyd Davidson)
  Re: cpu count (Kaz Kylheku)
  Re: cpu count (Oleg Levin)
  socket programming in c++ (Sebastian Rohde)
  Reading Linux file system from a Win 95 App. ([EMAIL PROTECTED])
  Re: ioctl not linked to anything? ("Guennadi V. Liakhovetski")
  Re: ioctl not linked to anything? (Andi Kleen)
  SHARE THE STACK (David)
  SHARE THE STACK (David)
  Re: lilo and minimize linux (David)
  Re: redirecting stdin to a memory buffer (Bob Steele)
  Re: SHARE THE STACK (Kaz Kylheku)
  Re: SHARE THE STACK (Kaz Kylheku)
  Re: SHARE THE STACK (Paul Repacholi)
  Re: SHARE THE STACK (Paul Repacholi)
  Re: Count? (The Ghost In The Machine)

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

From: Pat Shelton <[EMAIL PROTECTED]>
Subject: Re: smp and gcc
Date: Sat, 30 Dec 2000 22:15:28 -0700


It depends on what you mean.  You don't have to compile a program
for SMP, Linux supports SMP so different tasks will run in parallel.
If you want a parallel program then you will have to use threads or
different processes using shared memory.  The only compiler to
support parallel code is Fortran and there is Fortran 90, 95, and HPF.
Parallel compilers are available for Linux but they are not free.
Check out the NAS compiler, Portland Compiler, etc.  Search the web
for this stuff.

Regards.




Japie wrote:

> Hello
>
> I have a dual celeron board and I recently build gcc and make on it.
> They (and other apps) gave me the message that I have a
> i686-pc-linux-blah,blah.
> But is it possible to build programs special for smp?
> I can't find that anyware.
>
> --
>
> Groetjes Japie
>
>    .~.
>   / V \
>  /( _ )\
>    ^ ^


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

Date: Sun, 31 Dec 2000 00:38:01 -0600
From: Robert Redelmeier <[EMAIL PROTECTED]>
Subject: Re: cpu count

Oleg Levin wrote:
> May be somebody knows how can I determine the number of CPU, 
> without parsing /proc/stat or /proc/cpuinfo files ?

This is the easiest way.  The Linux kernel may export the 
number of CPUs in some other way. 

You can have a look at the code Intel suggests for starting-up
APs (secondary processors) in an SMP system in the IA32 Systems
Programming Manual.  IIRC, you've got to set up the APIC, and
issue an IPI from the ICR.  Lots of fun.

-- Robert

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

From: Floyd Davidson <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: redirecting stdin to a memory buffer
Date: 30 Dec 2000 21:05:41 -0900

[EMAIL PROTECTED] (Juergen Heinzl) wrote:
>Bob Steele wrote:
>>Does anyone know how to redirect stdin to a memory buffer in C. I am
>>using glibc 2.2 with GCC on a Red Had 7.0 linux box.
>>
>>For example:
>>stdin=(FILE *)freopen("test.txt","r",stdin);  correctly redirects stdin
...
>>fclose(stdin);
>>stdin=(FILE *)fmemopen(buffer,strlen(buffer),"r");
...
>It does, here's a slightly modified example.
>
>#include <stdio.h>
>static char buffer[] = "foobar";
>               
>int
>main()
>{
>  int ch;
>
>  fclose(stdin);
>  stdin = fmemopen (buffer, strlen (buffer), "r");
>  while((ch = fgetc (stdin)) != EOF)
>         printf ("Got %c\n", ch);
>
>  return 0;
>}

Both of the above methods should be avoided.  stdin is not
necessarily an lvalue, and should never be assigned to.  It may
work with any given platform/implementation, but the code is
inherently non-portable and may fail to compile on another
platform, or for that matter on the same platform with different
compiler options or different #defines enabled in the code.

The above code resulted in the following error on my machine:

tanana:floyd ~/tst >gcc -W -Wall foo.c
foo.c: In function `main':
foo.c:11: warning: implicit declaration of function `fmemopen'
foo.c:11: invalid lvalue in assignment

To redirect stdin from within a running program, all input
should be from a specified stream, which can be assigned stdin
or another FILE pointer.  For example, rewriting the above code:

#include <stdio.h>
char buffer[] = "foobar";
                
int main(void)
{
  int ch;
  FILE *input;

#if 0
  input = stdin;
#else
  input = fmemopen(buffer, strlen(buffer), "r");
#endif

  while((ch = fgetc(input)) != EOF)
    printf("Got %c\n", ch);

  return 0;
}



-- 
Floyd L. Davidson         <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska)                 [EMAIL PROTECTED]

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: cpu count
Reply-To: [EMAIL PROTECTED]
Date: Sun, 31 Dec 2000 07:06:03 GMT

On Sun, 31 Dec 2000 00:38:01 -0600, Robert Redelmeier <[EMAIL PROTECTED]> wrote:
>Oleg Levin wrote:
>> May be somebody knows how can I determine the number of CPU, 
>> without parsing /proc/stat or /proc/cpuinfo files ?
>
>This is the easiest way.  The Linux kernel may export the 
>number of CPUs in some other way. 

glibc 2.2 has a sysconf() for this. The LinuxThreads library uses this
internally because it has some SMP-dependent behaviors, such as the
new adaptive spinlocks.  I can't remember what the parameter constant
is; I'd have to go chomping through the sources, and I believe I've
dropped enough of a hint already to be excused from doing this. ;)

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

From: Oleg Levin <[EMAIL PROTECTED]>
Subject: Re: cpu count
Date: Sun, 31 Dec 2000 07:30:58 GMT

Kaz Kylheku wrote:

> On Sun, 31 Dec 2000 00:38:01 -0600, Robert Redelmeier <[EMAIL PROTECTED]> wrote:
> >Oleg Levin wrote:
> >> May be somebody knows how can I determine the number of CPU,
> >> without parsing /proc/stat or /proc/cpuinfo files ?
> >
> >This is the easiest way.  The Linux kernel may export the
> >number of CPUs in some other way.
>
> glibc 2.2 has a sysconf() for this. The LinuxThreads library uses this
> internally because it has some SMP-dependent behaviors, such as the
> new adaptive spinlocks.  I can't remember what the parameter constant
> is; I'd have to go chomping through the sources, and I believe I've
> dropped enough of a hint already to be excused from doing this. ;)

Unfortunely, I have glibc 2.1.2, but, anyway, thanks for your help

Oleg


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

From: Sebastian Rohde <[EMAIL PROTECTED]>
Subject: socket programming in c++
Date: Sun, 31 Dec 2000 12:45:11 +0100

I need to mak a programme which is able to handle various network connections
at once. I found a guide which set me on the right path but everything i know
now is c stuff. So my question is whether there are any c++ classes which
might be of some help for me.

For i am new to unix programming i hope somebody could point me into the right
direction. Thnx

        Sebastian Rohde
        [EMAIL PROTECTED]

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

From: [EMAIL PROTECTED]
Subject: Reading Linux file system from a Win 95 App.
Date: Sun, 31 Dec 2000 15:28:24 GMT



In The Name of GOD

Hi, I want to write windows application which should read a floppy
formatted with Linux file system and copy a file from floppy to hard
disk formatted with FAT File System

I don't know whether i can access the floppy disk formatted with
another file system using Win32 API or i need Lower level of access
(e.g, VXD access), If so, From where i should start?

Many thanks

Mostafa Kalantar


Sent via Deja.com
http://www.deja.com/

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

From: "Guennadi V. Liakhovetski" <[EMAIL PROTECTED]>
Subject: Re: ioctl not linked to anything?
Date: Sun, 31 Dec 2000 15:23:12 +0000

Hi

Thanks to all who replied! The great thing is that all the answers are
different!:-)

Well, I tried to find the actual definition of the ioctl() function in
libc, but so far failed - only found its declaration in sys/ioctl.h. To
save me some time and work - could anybody give me a hint? Or is it
weak_alias and __ioctl that do the job?

Happy New Year
Guennadi
___

Dr. Guennadi V. Liakhovetski
Department of Applied Mathematics
University of Sheffield, U.K.
email: [EMAIL PROTECTED]



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

From: Andi Kleen <[EMAIL PROTECTED]>
Subject: Re: ioctl not linked to anything?
Date: 31 Dec 2000 19:32:20 +0100

"Guennadi V. Liakhovetski" <[EMAIL PROTECTED]> writes:

> Thanks to all who replied! The great thing is that all the answers are
> different!:-)

Joys of usenet @)

> 
> WELL, I tried to find the actual definition of the ioctl() function in
> libc, but so far failed - only found its declaration in sys/ioctl.h. To
> save me some time and work - could anybody give me a hint? Or is it
> weak_alias and __ioctl that do the job?

It is.

To save you some work, the really multiplexer is 
/usr/src/linux/fs/ioctl.c:sys_ioctl()'s default case. The f_op vtable
is initialised in the driver's open function. 

-Andi

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

From: David <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system
Subject: SHARE THE STACK
Date: Sun, 31 Dec 2000 22:31:41 +0100

Hi, I want share program stack. I create file (ftruncate ...) and copy 
stack to that file. Then I try to make mmap (with al permisions ...), 
and I obtain "cant allocate memory". I cant make it with code and data 
segments.

Why cannot I mmap the stack ?
Any idea to share my program stack ?

thanks in advance,
DTM


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

From: David <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system
Subject: SHARE THE STACK
Date: Sun, 31 Dec 2000 22:31:41 +0100

Hi, I want share program stack. I create file (ftruncate ...) and copy 
stack to that file. Then I try to make mmap (with al permisions ...), 
and I obtain "cant allocate memory". I cant make it with code and data 
segments.

Why cannot I mmap the stack ?
Any idea to share my program stack ?

thanks in advance,
DTM


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

From: David <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.setup
Subject: Re: lilo and minimize linux
Date: Sun, 31 Dec 2000 22:43:21 +0100



Hung P. Tran wrote:

> I am trying to fit linux onto a 60 MB harddrive. Obviously, the
> drive is too small for a standard linux installation.
> 
> My first question is how to install lilo on the drive and make it
> boot linux. I tried to partition the drive using: fdisk /dev/hdc (the
> drive is connected as secondary IDE master). I just assign
> a single partition #1 (hdc1). Then I make the file system using mkfs, and
> then mount the harddrive as /mnt/d. Then I copy a few file from
> my original RedHat 6.1 over. Here is an output from  "ls -l /mnt/d"
> 
> total 927
> -rw-r--r--   1 root     root         4568 Oct 17 14:33 boot.b
> -rw-r--r--   1 root     root       285018 Oct 17 16:19 initrd.img
> -rw-r--r--   1 root     root          250 Oct 17 17:17 lilo.conf
> drwxr-xr-x   2 root     root        12288 Oct 17 14:30 lost+found
> -rw-------   1 root     root        13312 Oct 17 16:21 map
> -rw-r--r--   1 root     root       622784 Oct 17 16:18 vmlinuz
> 
> The new modified lilo.config is as followed:
> 
> boot=/dev/hdc
> map=/mnt/d/map
> install=/mnt/d/boot.b
> prompt
> timeout=50
> default=linux
> 
> image=/mnt/d/vmlinuz
>  label=linux
>  initrd=/mnt/d/initrd.img
>  read-only
>  root=/dev/hdc1
> 
> I then run: /sbin/lilo -C /mnt/d/lilo.conf
> 
> I then reboot the system and configure the BIOS to boot from the
> secondary master IDE (it can boot up fine from a secondary master IDE
> with DOS). However, I only get a bunch of 01 01 01 ... on the screen.
> 
> What did I do wrong ? What am I missing ?
> 
> I apologize for the long email. Any advice is appreciated.
> 
> Thank you in advance,
> 
> hung
01 01 01 01 means that lilo is not correct installed.
look for linux one disk. They are little distributions that put linux in 
one or two disc.
my lilo config is more simple than you. Try to remove options (for 
example map=...)

Last thing. Has you hdc partition activated ???
has you install lilo in mbr (dont say me that look your lilo.conf, 
because there was a lot time that I no read one).?

Good luck,
DTM


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

From: Bob Steele <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.apps,comp.programming,linux.redhat.development,comp.os.development,linux.dev.gcc,linux.dev.c-programming
Subject: Re: redirecting stdin to a memory buffer
Date: Sun, 31 Dec 2000 20:17:20 GMT

Juergen, you seem to have solved the problem.  I successfully compiled the
code that you provided under
Red Hat 7.0. using 'gcc -g foo.c -o foo -D_GNU_SOURCE'  Unfortunately, it
seems that you pointed me
to the real problem.  When I tested the original code, I used getchar() to
retrieve the test data.  getchar() is
equivalent to getc(stdin).  Strangely enough, the problem I encountered
manifests itself only when getchar() is
used but not getc(stdin) or fgetc(stdin) is used.

Floyd Davidson (and several others) pointed out that this technique is not
portable and I agree with him.  Fortunately,
the project that I am working on will never be ported to other platforms.
The code that Juergan provided is (or should be) portable between GNU
ports.  A very good point that Floyd made is that this technique may fail
even on the intended platform.

In the quest to find a work around, I've glanced at the source for freopen()
and fmemopen() and think that problem
_MAY_ lie inside the design of the library.  If that is truly the case, then
a need for a fmemreopen function _COULD_
possibly exist.  To design such a function would be totally unportable, and
definitely a time bomb, even on the intended
platform.

Before flaming me about the above paragraph, please keep in mind that I used
a lot of may's and could's as I am only
speculating without knowing the big picture.  In other word's, I am only
tempting to generate discussion.  Lastly, I
guess Floyd's warning is already ringing true.
Bob Steele
email: [EMAIL PROTECTED]

Juergen Heinzl wrote:

> In article <[EMAIL PROTECTED]>, Bob Steele wrote:
> >Does anyone know how to redirect stdin to a memory buffer in C. I am
> >using glibc 2.2 with GCC on a Red Had 7.0 linux box.
> >
> >For example:
> >stdin=(FILE *)freopen("test.txt","r",stdin);  correctly redirects stdin
> >to a file "test.txt".
> >
> >However, since there is no reopen function for memory buffers, I am
> >forced to use;
> >
> >fclose(stdin);
> >stdin=(FILE *)fmemopen(buffer,strlen(buffer),"r");
> [-]
> Works fine for me -- what's that (FILE *) for though ? You had
> better use -D_GNU_SOURCE to avoid a warning.
>
> >According to the GNU man GLIBC web pages, this should redirect stdin to
> >read input from the buffer. Unfortunately, this does not seem to work.
> >It simply returns an EOF character indicating an error condition.
> [-]
> It does, here's a slightly modified example.
>
> #include <stdio.h>
> static char buffer[] = "foobar";
>
> int
> main()
> {
>   int ch;
>
>   fclose(stdin);
>   stdin = fmemopen (buffer, strlen (buffer), "r");
>   while((ch = fgetc (stdin)) != EOF)
>          printf ("Got %c\n", ch);
>
>   return 0;
> }
>
> If it doesn't work for you it's a RH problem
>
> Cheers,
> Juergen
>
> --
> \ Real name     : Jürgen Heinzl         \       no flames      /
>  \ EMail Private : [EMAIL PROTECTED] \ send money instead /


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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.system
Subject: Re: SHARE THE STACK
Reply-To: [EMAIL PROTECTED]
Date: Sun, 31 Dec 2000 21:09:30 GMT

On Sun, 31 Dec 2000 22:31:41 +0100, David <[EMAIL PROTECTED]> wrote:
>Hi, I want share program stack. I create file (ftruncate ...) and copy 
>stack to that file. Then I try to make mmap (with al permisions ...), 
>and I obtain "cant allocate memory". I cant make it with code and data 
>segments.
>
>Why cannot I mmap the stack ?

Because it's, like, already mapped and you can't map two things to
the same address range?

>Any idea to share my program stack ?

Why would you want to do a silly thing like that? Stacks are not even
shared among threads in the same process!

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.system
Subject: Re: SHARE THE STACK
Reply-To: [EMAIL PROTECTED]
Date: Sun, 31 Dec 2000 21:09:30 GMT

On Sun, 31 Dec 2000 22:31:41 +0100, David <[EMAIL PROTECTED]> wrote:
>Hi, I want share program stack. I create file (ftruncate ...) and copy 
>stack to that file. Then I try to make mmap (with al permisions ...), 
>and I obtain "cant allocate memory". I cant make it with code and data 
>segments.
>
>Why cannot I mmap the stack ?

Because it's, like, already mapped and you can't map two things to
the same address range?

>Any idea to share my program stack ?

Why would you want to do a silly thing like that? Stacks are not even
shared among threads in the same process!

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

Crossposted-To: comp.os.linux.development.system
Subject: Re: SHARE THE STACK
From: Paul Repacholi <[EMAIL PROTECTED]>
Date: 01 Jan 2001 04:34:05 +0800

David <[EMAIL PROTECTED]> writes:

> Hi, I want share program stack. I create file (ftruncate ...) and copy
> stack to that file. Then I try to make mmap (with al permisions ...),
> and I obtain "cant allocate memory". I cant make it with code and data
> segments.
> 
> Why cannot I mmap the stack ?
> Any idea to share my program stack ?

Why don't you tell us what you are trying to get done?
Then someone may be able to help. But sharing the stack is
probably not the answer.

Oh, and the machine, version etc would help.

-- 
Paul Repacholi                               1 Crescent Rd.,
+61 (08) 9257-1001                           Kalamunda.
                                             West Australia 6076
Raw, Cooked or Well-done, it's all half baked.

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

Crossposted-To: comp.os.linux.development.system
Subject: Re: SHARE THE STACK
From: Paul Repacholi <[EMAIL PROTECTED]>
Date: 01 Jan 2001 04:34:05 +0800

David <[EMAIL PROTECTED]> writes:

> Hi, I want share program stack. I create file (ftruncate ...) and copy
> stack to that file. Then I try to make mmap (with al permisions ...),
> and I obtain "cant allocate memory". I cant make it with code and data
> segments.
> 
> Why cannot I mmap the stack ?
> Any idea to share my program stack ?

Why don't you tell us what you are trying to get done?
Then someone may be able to help. But sharing the stack is
probably not the answer.

Oh, and the machine, version etc would help.

-- 
Paul Repacholi                               1 Crescent Rd.,
+61 (08) 9257-1001                           Kalamunda.
                                             West Australia 6076
Raw, Cooked or Well-done, it's all half baked.

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

From: [EMAIL PROTECTED] (The Ghost In The Machine)
Subject: Re: Count?
Date: Sun, 31 Dec 2000 21:59:55 GMT

In comp.os.linux.development.system, Mark R. Holbrook
<[EMAIL PROTECTED]>
 wrote
on Wed, 13 Dec 2000 21:59:51 -0800
<[EMAIL PROTECTED]>:
>Back in my Unix/Xenix days there used to be a command called "count".
>
>This was a handy thing to do things like:  ps -ef | count to tell you
>how many processes were running.  Or... who | count would tell you how
>many people were logged in.
>
>What ever happened to count?
>
>Mark

ps -ef --no-headers | wc -l

should take care of that.

'man ps' and 'man wc' for details.

-- 
[EMAIL PROTECTED] -- insert random misquote here
                    up 92 days, 22:20, running Linux.

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


** 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