Re: "iowait" CPU state

2000-11-16 Thread Terry Lambert

> > > I guess it might be useful to see the difference between
> > > "true" idle time and time the system couldn't do anything
> > > useful because it was blocked on the disk (but /should/
> > > have done something useful...).
> > 
> > You mean because the programmer didn't interleave their I/O,
> > and wrote to a threads interface, or some other interface
> > that's prone to subsystem stalling, instead?
> 
> Interleaving IO only makes sense when you have tons of
> parallelisable jobs. If you have one big serial job this
> doesn't buy you anything...

Then neither does looking at how it's not running.  8-).


> Yes, you can use a separate thread to queue IO in
> advance, but in this case it might just be useful to
> have the %iowait statistic so you know how much work
> to queue in advance.

These statistics are only available to priviledged programs
and/or programs willing to popen() priviledged programs.


> Then again, this may be a bad example. I can't quite
> put my finger on it, but somehow I have the idea that
> the %iowait may be a useful statistic to keep...

It's not there now.


> > Modern bloat-ware really pisses me off; I built the bind
> > library the other day: the frigging thing was 4M, unstripped.
> 
> How does this affect the (non?-)usefullness of the
> %iowait statistic?

When you are waiting for I/O in a well written program, it
is because there's nothing left to do but wait, which would
make the statistic useless.  If there's something else you
could do, and you're waiting, by definition the program is
not well written (well written programs don't waste time for
no good reason).

In a badly written program, I guess you could argue that a
manager could use it to decide who didn't think before they
wrote their code, for things like proportioning merit raises
or pink slips, based on whether or not someone thought before
they wrote their code...


Terry Lambert
[EMAIL PROTECTED]
---
Any opinions in this posting are my own and not those of my present
or previous employers.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: changing a running process's credentials

2000-11-16 Thread Stefan `Sec` Zehl

On Wed, Nov 15, 2000 at 06:02:22PM +0100, Peter Pentchev wrote:
> On Wed, Nov 15, 2000 at 08:47:22AM -0800, Alfred Perlstein wrote:
> > * Peter Pentchev <[EMAIL PROTECTED]> [001115 06:19] wrote:
> > > As far as I can see, FreeBSD (nor any other Unix system I'm aware
> > > of) does not provide a way to do this (short of writing to
> > > /dev/kmem ;).  If a new syscall should be implemented to this end,
> > > would it be enough to change a struct proc's p_cred member, its
> > > pc_ucred and such, or would that raise hell all over the process
> > > table?  I see the comments mentioning 'possibly shared'
> > > credentials - does this mean that I can inadvertently change the
> > > credentials of a whole process children/siblings tree?  That does
> > > not sound too good - how do I go about taking a single process's
> > > credentials out - just allocate a new pcred/ucred structure?
> > 
> > Struct ucred is read-only, that would mean that strange things may
> > happen, fortunatly at the moment most access control checks are
> > only done at file open/socket bind time, so that if your cred
> > changes you should still have access to it.
> > 
> > > And yes, I'm quite aware of the security implications of something like
> > > that.. let's just say I like playing with fire in a controlled
> > > environment :) (famous last words..)
> > 
> > Well there wouldn't be any security implications if done right...
> 
> The security implications I meant have to do with the ability to provide
> either a tool or a sysctl to change the uid of any running process
> on the system - that would have to include stringent controls on exactly
> who and why uses this tool/sysctl.  I have some ideas about this,
> but they need some more grinding before they're ready to be tossed
> at the world for discussion (and dissing ;)

A few years ago (Feb-1997 on FreeBSD-2.1.0) i wrote a little
proof-of-concept program to show that write access means instant root.

It uses stolen parts from the kvm lib and /bin/ps to do it.
I ported it to FreeBSD-3.2 a year ago, and it compiles and runs on 4.1
also.
I found it really handy when I start to edit a file to which i have no
write access. I can promote vi to root, and write the file instead of
fiddling around with temp-files ;-)

I've put the source at 
in case anyone wants it.

Of course it will only work as root, as write access to /dev/kmem is
needed. Do not make /dev/kmem group or even world writable ;-)

If this code is usefull for anyone else, i'd be happy to hear about it
;-)

CU,
Sec
-- 
My biggest problem was when I screwed up the device driver for my eyelids
I couldn't open my eyes to debug them.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Nicolai Petri

What's the best approach for a simple web-server(never more the 10 clients)
? Is it using pthread and a thread per connection . Or to make a
non-blocking single thread server. Can people show me some simple examples
of the 2 techniques ?

And what's the pro's and con's for the 2 methods ???

---
Cheers,
Nicolai Petri

// *If you can't follow the standard, break it (MickeySoft)*



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Any known issue about icmp replies ?

2000-11-16 Thread Remy Nonnenmacher

On 16 Nov, Mike Silbersack wrote:
> 
> On Thu, 16 Nov 2000, Eugene Polovnikov wrote:
> 
>> Are you sure that your system isn't hacked/cracked ?
>> Content of packets look strange for me.
> 
> Yeah, now that you suggested that, I checked - that's Stacheldraht's
> handiwork.
> 
> Unplug the box soon, Remy!
> 
> Mike "Silby" Silbersack
> 

OK. got the reference. I simply dropped any icmp packets to this machine
of no importance. It's amazing to find such a breach known for a year
and  not fixed.

Well. I'm getting more and more convinced that L will be the next W$...

Thanks.

RN.
IeM




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



More detail on Deskpro XL6200 NIC (was: Legacy ethernet cards inFreeBSD)

2000-11-16 Thread Koster, K.J.

Dear Bill, others,

I've been working on getting my Deskpros to use their NIC under 4.2, but no
luck. The problem is as follows: I installed 4.0, and the NIC came up under
the lnc driver, reports its MAC address and works fine.

--
FreeBSD 4.0-RELEASE #0: Mon Mar 20 22:50:22 GMT 2000
[EMAIL PROTECTED]:/usr/src/sys/compile/GENERIC
...
lnc0:  port 0x7000-0x701f irq 5 at device 11.0
on pci0
lnc0: supplying EUI64: 00:80:5f:ff:fe:fa:a0:82
lnc0: PCnet-32 VL-Bus address 00:80:5f:fa:a0:82
lnc0: driver is using old-style compatability shims
--

In 4.2, the lnc driver still probes and finds the NIC, but does not report
finding a MAC address, and the NIC remains dead.

--
FreeBSD 4.2-BETA #0: Thu Nov 16 11:03:15 CET 2000
[EMAIL PROTECTED]:/usr/obj/usr/src/sys/QUAM
...
lnc0:  port 0x7000-0x701f irq 5 at device 11.0
on pci0
lnc0: driver is using old-style compatability shims
---

Compiling a kernel with the pcn driver does not help. Booting a lnc+pcn
kernel causes the behaviour described above, booting a pcn-only kernel makes
the NIC show up as an unknown device, vendor 0x1022, device 0x2000.

--
pci0:  (vendor=0x1022, dev=0x2000) at 11.0 irq 5
--

Looking in the source shows that the pcn driver knows about this
vendor/device combination. Booting -v does not show any attempts on pcn's
part to take the card into its arms.

--
avail memory = 62328832 (60868K bytes)
bios32: Bad BIOS32 Service Directory
Other BIOS signatures found:
ACPI: 
Preloaded elf kernel "kernel" at 0xc0308000.
Preloaded userconfig_script "/boot/kernel.conf" at 0xc03080a8.
Pentium Pro MTRR support enabled
pci_open(1):mode 1 addr port (0x0cf8) is 0xa06c
pci_open(1a):   mode1res=0x8000 (0x8000)
pci_cfgcheck:   device 0 1 2 3 4 5 6 7 8 9 10 11 [class=02] [hdr=00] is
there (id=20001022)
npx0:  on motherboard
npx0: INT 16 interface
pci_open(1):mode 1 addr port (0x0cf8) is 0x
pci_open(1a):   mode1res=0x8000 (0x8000)
pci_cfgcheck:   device 0 1 2 3 4 5 6 7 8 9 10 11 [class=02] [hdr=00] is
there (id=20001022)
pcib0:  on motherboard
found-> vendor=0x1022, dev=0x2000, revid=0x02
class=02-00-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
intpin=b, irq=5
map[10]: type 1, range 32, base 7000, size  5
found-> vendor=0x1022, dev=0x2020, revid=0x02
class=01-00-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
intpin=a, irq=10
map[10]: type 1, range 32, base 7100, size  7
found-> vendor=0x102b, dev=0x0519, revid=0x01
class=03-00-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
intpin=a, irq=255
map[10]: type 1, range 32, base 0420, size 14
map[14]: type 1, range 32, base 0480, size 23
found-> vendor=0x10ec, dev=0x8139, revid=0x10
class=02-00-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
intpin=a, irq=5
map[10]: type 1, range 32, base 6000, size  8
map[14]: type 1, range 32, base 4000, size  8
found-> vendor=0x0e11, dev=0x0001, revid=0x07
class=06-02-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
found-> vendor=0x8086, dev=0x84c5, revid=0x04
class=05-00-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
found-> vendor=0x8086, dev=0x84c4, revid=0x04
class=06-00-00, hdrtype=0x00, mfdev=0
subordinatebus=0secondarybus=0
pci0:  on pcib0
lnc0:  port 0x7000-0x701f irq 5 at device 11.0
on pci0
lnc0: driver is using old-style compatability shims
--

What am I missing?

Kees Jan


 You are only young once,
   but you can stay immature all your life.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



running lastest ggi demos on R4.1.1

2000-11-16 Thread Nicolas Souchu

Hi hackers,

Has anyone been able to run the latest GGI stuff on a stable box?

The port graphics/libggi is outdated. The problem seems to be when
the execution enters the X library...

There package is really easy-to-compile. Any X advanced user to give
it a try?

(gdb) core-file lt-demo.core 
Core was generated by `lt-demo'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/local/contrib/degas/lib/libggi/ggi/.libs/libggi.so.2...done.
Reading symbols from /usr/local/lib/libgii.so.0...done.
Reading symbols from /usr/local/lib/libgg.so.0...done.
Reading symbols from /usr/lib/libc.so.4...done.
Reading symbols from /usr/local/lib/ggi/display/X.so...done.
Reading symbols from /usr/local/lib/libggi.so.2...done.
Reading symbols from /usr/X11R6/lib/libX11.so.6...done.
Reading symbols from /usr/X11R6/lib/libXext.so.6...done.
Reading symbols from /usr/X11R6/lib/libXThrStub.so.6...done.
Reading symbols from /usr/local/lib/ggi/input/xwin.so...done.
Reading symbols from /usr/local/lib/ggi/display/mansync.so...done.
Reading symbols from /usr/libexec/ld-elf.so.1...done.
#0  0x28153907 in XCreateWindow () from /usr/X11R6/lib/libX11.so.6
(gdb) where
#0  0x28153907 in XCreateWindow () from /usr/X11R6/lib/libX11.so.6
#1  0x2811521c in GGIdl_X () at mode.inc:393
#2  0x2806b3fd in ggiSetMode () at mode.c:68
#3  0x804941b in main (argc=0, argv=0xbfbffb94) at demo.c:379
#4  0x8048ec1 in _start ()

Thanks,

Nicholas

-- 
Nicolas Souchu
AlcĂ´ve - Open Source Software Engineer - http://www.alcove.fr


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Nicolai Petri

> From: <[EMAIL PROTECTED]>
> On Thu, 16 Nov 2000, Nicolai Petri wrote:
> > What's the best approach for a simple web-server(never more the 10
clients)
> > Is it using pthread and a thread per connection .
> That is probably simplest from a programming point of view.
That's sounds fine to me.. :o)

> > Or to make a
> > non-blocking single thread server.
> That will probably give you the best performance. It willl probably use
> slightly less RAM as well but not enough to be of an issue unless you are
> trying to fit in 4MB or something.
I've got plenty of RAM. It's more a question of stability / simplicity.

> > Can people show me some simple examples
> > of the 2 techniques ?
> As in web servers that use one or the other method or are you just after
> software that uses pthreads and/or non blocking I/O?
> For non blocking I/O you are probably after select, poll or kqueue.
I'm quite lost here.. Is there a good reason for using kqueue instead of
select/poll ?

> I have a basic program that uses pthreads if that will help...it uses
> kqueue as well although not for non blocking I/O. Its not finished but the
> threading part works...
I would love to see the code.. I'm having some stability problems with my
own code. Maybe I can figure out where I went wrong.

> > And what's the pro's and con's for the 2 methods ???
>
> It really does depend on what you're trying to acheive...I'd tend to go
> for the threads solution with the argument that the programmers time is
> worth far more than the extra hardware it would take to make up any minor
> performance penalty.
I personally prefer the most simple and failsafe solution. Too much
performance hunting will often give less understandable/debugable code.

---
Thanks for your good answers.
- Nicolai Petri




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: "iowait" CPU state

2000-11-16 Thread Rik van Riel

On Thu, 16 Nov 2000, Terry Lambert wrote:

> > > Modern bloat-ware really pisses me off; I built the bind
> > > library the other day: the frigging thing was 4M, unstripped.
> > 
> > How does this affect the (non?-)usefullness of the
> > %iowait statistic?
> 
> When you are waiting for I/O in a well written program, it
> is because there's nothing left to do but wait, which would
> make the statistic useless.  If there's something else you
> could do, and you're waiting, by definition the program is
> not well written (well written programs don't waste time for
> no good reason).

Ummm, how about a situation where you have a steadily
increasing work load (more customers?) and want to have
decent statistics of your servers to determine exactly
what parts to upgrade and/or if you need to put extra
machines into service?

I agree that *any* statistics become useless after some
time in a completely static situation, but thruth is that
the number of internet users is still increasing and the
workload on servers is doing the same ;)

regards,

Rik
--
"What you're running that piece of shit Gnome?!?!"
   -- Miguel de Icaza, UKUUG 2000

http://www.conectiva.com/   http://www.surriel.com/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



make install world

2000-11-16 Thread Jamie Heckford

Hi,

During make install world, I keep having it stop complaining "xxx Directory:
Not Found"

If i manually create this directorys with mkdir, and re-run make install world,
it works fine, but then stops when it cant find a different directory.

Is their any way I can have make install world or is their something I can run
before that to create the missing directorys manually?

Thanks,

-- 
Jamie Heckford
Chief Network Engineer
Psi-Domain - Innovative Linux Solutions. Ask Us How.

===
email: [EMAIL PROTECTED]
web: http://www.psi-domain.co.uk/

tel:   +44 (0)1737 789 246
fax:   +44 (0)1737 789 245
mobile:+44 (0)7779 646 529
===


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Alex Belits

On Thu, 16 Nov 2000, Nicolai Petri wrote:

> What's the best approach for a simple web-server(never more the 10 clients)
> ? Is it using pthread and a thread per connection . Or to make a
> non-blocking single thread server. Can people show me some simple examples
> of the 2 techniques ?
> 
> And what's the pro's and con's for the 2 methods ???

  I would prefer one process without nonblocking i/o, as multithreaded
program easily becomes hard to manage if you have any more or less complex
data model. However even apache-style multiple processes will work, and 
will be even simplier than either -- the disadvantage is only that it
will have to keep all processes independent, so some kinds of
processing will be hard to implement.

  I wrote my own HTTP server (fhttpd) that combines nonblocking main
process and multiple backend modules processes that can be blocking or
nonblocking -- it's possible that what you are trying to accomplish can
be done in fhttpd module without writing a full-blown server.

-- 
Alex

--
 Excellent.. now give users the option to cut your hair you hippie!
  -- Anonymous Coward



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: make install world

2000-11-16 Thread Johan Karlsson

Hi

Are you actually using
#make install world 
???

I think you want
#make installworld
after you succesfully build the world using
#make buildworld

/Johan K

At Thu, 16 Nov 2000 12:18:40 GMT, Jamie Heckford wrote:
> Hi,
> 
> During make install world, I keep having it stop complaining "xxx Directory:
> Not Found"
> 
> If i manually create this directorys with mkdir, and re-run make install worl
>d,
> it works fine, but then stops when it cant find a different directory.
> 
> Is their any way I can have make install world or is their something I can ru
>n
> before that to create the missing directorys manually?
> 
> Thanks,
> 
> -- 
> Jamie Heckford
> Chief Network Engineer
> Psi-Domain - Innovative Linux Solutions. Ask Us How.
> 
> ===
> email: [EMAIL PROTECTED]
> web:   http://www.psi-domain.co.uk/
> 
> tel: +44 (0)1737 789 246
> fax: +44 (0)1737 789 245
> mobile:  +44 (0)7779 646 529
> ===
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Geoff Buckingham

On Thu, Nov 16, 2000 at 11:38:14AM +0100, Nicolai Petri wrote:
> What's the best approach for a simple web-server(never more the 10 clients)
> ? Is it using pthread and a thread per connection . Or to make a
> non-blocking single thread server. Can people show me some simple examples
> of the 2 techniques ?
> 
Depending on exactly what you are trying to achieve you may want to take a 
look at thttpd, if you have not allready seen it.

It is select based though:

http://www.acme.com/software/thttpd/notes.html#select

-- 
GeoffB 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: scheduler activations in FBSD5.0?

2000-11-16 Thread Daryl Chance

Is there a FreeBSD 5.0 Stable or is there only a current
and stable reserved for the current release version (4.X).

Thanks,
-
Daryl Chance   | And which parallel universe did
ValueData, LLC | YOU crawl out of?
Memphis, TN|  - http://www.thinkgeek.com
- Original Message -
From: "Alfred Perlstein" <[EMAIL PROTECTED]>
To: "frank xu" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, November 16, 2000 1:30 AM
Subject: Re: scheduler activations in FBSD5.0?


> * frank xu <[EMAIL PROTECTED]> [001115 23:15] wrote:
> > I heard rumor that Thomas E. Anderson's Scheduler Activations theory
will
> > be implemented in FreeBSD 5.0 kernel, is it true?
>
> Several people have begun the initial development on it.
>
> --
> -Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
> "I have the heart of a child; I keep it in a jar on my desk."
>
>
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
>



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: scheduler activations in FBSD5.0?

2000-11-16 Thread Pedro F Giffuni

http://people.FreeBSD.org/~jasone/kse/

On Thu, 16 Nov 2000, frank xu wrote:

> I heard rumor that Thomas E. Anderson's Scheduler Activations theory will
> be implemented in FreeBSD 5.0 kernel, is it true?
> 
> Regards,
> XuYifeng
> 
> _
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> Share information about yourself, create your own public profile at 
> http://profiles.msn.com.
> 
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Sound card support

2000-11-16 Thread Jamie Heckford

Hi,

I have an onboard sound card, and am trying to get it to work with FreeBSD.

At boot, I have the following message:

chip1:  port 0xdc00-0xdc3f,0xd800-0x
d8ff irq 5 at device 31.5 on pci0

And in my Kernel:

# Sound

device  pcm

This does not work though. Does anyone have any suggestions? I am using 
FreeBSD 4.2-BETA

Thanks,

-- 
Jamie Heckford
Chief Network Engineer
Psi-Domain - Innovative Linux Solutions. Ask Us How.

===
email: [EMAIL PROTECTED]
web: http://www.psi-domain.co.uk/

tel:   +44 (0)1737 789 246
fax:   +44 (0)1737 789 245
mobile:+44 (0)7779 646 529
===


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Sound card support

2000-11-16 Thread Dimitar Peikov

http://www.katsurajima.seya.yokohama.jp/ich/

Have fun. It works fine for me!
-- 
Dimitar Peikov
Programmer Analyst
"We Build e-Business"  

RILA Solutions  
27 Building, Acad.G.Bonchev Str.  
1113 Sofia, Bulgaria  
home:  (+359 2)  595495
phone: (+359 2) 9797320 
phone: (+359 2) 9797300 
fax:   (+359 2) 9733355  
http://www.rila.com 




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: scheduler activations in FBSD5.0?

2000-11-16 Thread Warner Losh

In message <001d01c04fdc$9e2e2e80$020a@mike> "Daryl Chance" writes:
: Is there a FreeBSD 5.0 Stable or is there only a current
: and stable reserved for the current release version (4.X).

STABLE is reserved for those branches that have had a release on
them.  Since there's been no 5.0 release yet, it doesn't have a STABLE
version.  That's why it is called -current.

Warner




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: scheduler activations in FBSD5.0?

2000-11-16 Thread Julian Elischer

frank xu wrote:
> 
> I heard rumor that Thomas E. Anderson's Scheduler Activations theory will
> be implemented in FreeBSD 5.0 kernel, is it true?

Basically the coming FreeBSD threading system will be based on the work
by
Anderson. It may have some different aspects too.

I see someone already sent you the reference on how the plans are
progressing
at this time

> 
> Regards,
> XuYifeng

-- 
  __--_|\  Julian Elischer
 /   \ [EMAIL PROTECTED]
(   OZ) World tour 2000
---> X_.---._/  presently in:  Budapest
v


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



FreeBSD VM

2000-11-16 Thread Raymond Law

majflt doesn't increase when a process is generating page faults.  Instead, 
the swapper process (pid 0) gets all the page faults and it is the same as 
the page faults given by cnt in vmmeter.c.  Why is this happening?  Is 
there a way to get the number of page faults generated by a SINGLE process?

proc *p;
num_pageflts = p->p_stats->p_ru.majflt

The above doesn't get increased.

Thanks.
Ray,



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



RTP as system calls.

2000-11-16 Thread Yonny Cardenas B.

Hello 

I want you to ask a favor. 

I'm incorporating the Real Time Transport Protocol(RTP) to FreeBSD
Kernel.

I want use the RTP Library API developed by Lucent
http://www.cs.columbia.edu/~hgs/rtplib/rtplib-1.0a1/rtp_api.html

First, I want try if this API can be add to Kernel as system calls.

I know this a little crazy but I think that is possible, with
corrections of course.

I compiled with the Kernel this APIs without problems. But I have 
problems linking kernel. The following message is show it:

cc -c -O -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes 
-Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual 
-fformat-extensions -ansi  -nostdinc -I- -I. -I../.. -I/usr/include 
-D_KERNEL -include opt_global.h -elf  -mpreferred-stack-boundary=2 
vers.c
linking kernel
init_sysent.o(.data+0xb8c): undefined reference to `RTPSend'
init_sysent.o(.data+0xc0c): undefined reference to `RTPSchedule'
rtp_unix.o: In function `_sys_bind':
rtp_unix.o(.text+0x141): undefined reference to `__error'
rtp_unix.o: In function `_sys_send':
rtp_unix.o(.text+0x1c8): undefined reference to `send'
rtp_unix.o: In function `random32':
rtp_unix.o(.text+0x23d): undefined reference to `clock'
rtp_unix.o(.text+0x253): undefined reference to `gethostid'

I don't understand the message "undefined reference to", 
for example the function "send" is a socket API. 

In the file rtp_unix.c you can see:

  #include 
  #include 
  ...

  int _sys_send(socktype skt, char *buf, int buflen, int flags) {
int res;
res = send(skt, buf, buflen, flags);
return(res);
  }

In the Kernel Makefile: 
  rtp_unix.o: $S/kern/rtp/rtp_unix.c 
${NORMAL_C}

In the RTPLibrary Makefile: 
  rtp_unix.o: rtp_unix.c rtp_unix.h rtp_api.h sysdep.h config.h


I have some questions:

1) Can I call functions level's user into kernel, as socket() or
calloc() ? 

2) How must I use the global variable "errno" for value 
returned for system calls ? Is sufficient with  #include  ?

3) How can I solve above linking errors.

Thanks for your help.

+--+
| YONNY CARDENAS B. Apartado Aereo  22828  |
| Systems Engineer  Santafe de Bogota D.C. |
|   Colombia - South America   |
| Student M.Sc. Tels:   +571 6095477   | 
| UNIVERSIDAD DE LOS ANDES  mailto: [EMAIL PROTECTED]   | 
|   [EMAIL PROTECTED] |
+--+
UNIX is BSD, and FreeBSD is an advanced 4.4BSD


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



New sound driver

2000-11-16 Thread Jamie Heckford

Hi,

I tried to get my onboard intel AC'97 card to work, and used a third party
driver to get success (written by Katsurajima Naoto)

The following card is:

pcm0: http://www.psi-domain.co.uk/

tel:   +44 (0)1737 789 246
fax:   +44 (0)1737 789 245
mobile:+44 (0)7779 646 529
===


/*
 * Copyright (c) 2000 Katsurajima Naoto <[EMAIL PROTECTED]>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD$
 */

#include 
#include 

#include 
#include 


/*  */

#define ICH_RECPRIMARY 0

#define ICH_TIMEOUT 1000 /* semaphore timeout polling count */

#define PCIR_NAMBAR 0x10
#define PCIR_NABMBAR 0x14

/* Native Audio Bus Master Control Registers */
#define ICH_REG_PI_BDBAR 0x00
#define ICH_REG_PI_CIV   0x04
#define ICH_REG_PI_LVI   0x05
#define ICH_REG_PI_SR0x06
#define ICH_REG_PI_PICB  0x08
#define ICH_REG_PI_PIV   0x0a
#define ICH_REG_PI_CR0x0b
#define ICH_REG_PO_BDBAR 0x10
#define ICH_REG_PO_CIV   0x14
#define ICH_REG_PO_LVI   0x15
#define ICH_REG_PO_SR0x16
#define ICH_REG_PO_PICB  0x18
#define ICH_REG_PO_PIV   0x1a
#define ICH_REG_PO_CR0x1b
#define ICH_REG_MC_BDBAR 0x20
#define ICH_REG_MC_CIV   0x24
#define ICH_REG_MC_LVI   0x25
#define ICH_REG_MC_SR0x26
#define ICH_REG_MC_PICB  0x28
#define ICH_REG_MC_PIV   0x2a
#define ICH_REG_MC_CR0x2b
#define ICH_REG_GLOB_CNT 0x2c
#define ICH_REG_GLOB_STA 0x30
#define ICH_REG_ACC_SEMA 0x34
/* Status Register Values */
#define ICH_X_SR_DCH   0x0001
#define ICH_X_SR_CELV  0x0002
#define ICH_X_SR_LVBCI 0x0004
#define ICH_X_SR_BCIS  0x0008
#define ICH_X_SR_FIFOE 0x0010
/* Control Register Values */
#define ICH_X_CR_RPBM  0x01
#define ICH_X_CR_RR0x02
#define ICH_X_CR_LVBIE 0x04
#define ICH_X_CR_FEIE  0x08
#define ICH_X_CR_IOCE  0x10
/* Global Control Register Values */
#define ICH_GLOB_CTL_GIE  0x0001
#define ICH_GLOB_CTL_COLD 0x0002 /* negate */
#define ICH_GLOB_CTL_WARM 0x0004
#define ICH_GLOB_CTL_SHUT 0x0008
#define ICH_GLOB_CTL_PRES 0x0010
#define ICH_GLOB_CTL_SRES 0x0020
/* Global Status Register Values */
#define ICH_GLOB_STA_GSCI   0x0001
#define ICH_GLOB_STA_MIINT  0x0002
#define ICH_GLOB_STA_MOINT  0x0004
#define ICH_GLOB_STA_PIINT  0x0020
#define ICH_GLOB_STA_POINT  0x0040
#define ICH_GLOB_STA_MINT   0x0080
#define ICH_GLOB_STA_PCR0x0100
#define ICH_GLOB_STA_SCR0x0200
#define ICH_GLOB_STA_PRES   0x0400
#define ICH_GLOB_STA_SRES   0x0800
#define ICH_GLOB_STA_SLOT12 0x7000
#define ICH_GLOB_STA_RCODEC 0x8000
#define ICH_GLOB_STA_AD30x0001
#define ICH_GLOB_STA_MD30x0002
#define ICH_GLOB_STA_IMASK  (ICH_GLOB_STA_MIINT | ICH_GLOB_STA_MOINT | ICH_GLOB_STA_PIINT | ICH_GLOB_STA_POINT | ICH_GLOB_STA_MINT | ICH_GLOB_STA_PRES | ICH_GLOB_STA_SRES)

/* AC'97 power/ready functions */
#define AC97_POWER_PINPOWER  0x0100
#define AC97_POWER_PINREADY  0x0001
#define AC97_POWER_POUTPOWER 0x0200
#define AC97_POWER_POUTREADY 0x0002

/* play/record buffer */
#define ICH_FIFOINDEX 32
#define ICH_BDC_IOC 0x8000
#define ICH_BDC_BUP 0x4000
#define ICH_DEFAULT_BLOCKSZ 2048
/* buffer descriptor */
struct ich_desc {
	volatile u_int32_t buffer;
	volatile u_int32_t length;
};

struct sc_info;

/* channel registers */
struct sc_chinfo {
	int run, spd, dir, fmt;
	snd_dbuf *buffer;
	pcm_channel *channel;
	struct sc_info *parent;
	struct ich_desc *index;
	u_int32_t lvi;
};

/* device private data */
struct sc_info {
	device_t	dev;
	u_int32_t 	type, rev;
	u_int32_t	cd2id, ctrlbase;

	struct resource *nambar, *nabmbar;
	int		nambarid, nabmbarid;
	bus_space_tag_t nambart, nabmbart;
	bus_space_handle_t nambarh, nabmbarh;
	bus

Re: changing a running process's credentials

2000-11-16 Thread void

Does anyone remember the article in Phrack, issue 53 I think, about
speaking Forth to a Sun's boot-prom in order to write a '0' into the UID
member of one's shell's struct proc?

-- 
 Ben

220 go.ahead.make.my.day ESMTP Postfix


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: changing a running process's credentials

2000-11-16 Thread David Scheidt

On Thu, 16 Nov 2000, void wrote:

:Does anyone remember the article in Phrack, issue 53 I think, about
:speaking Forth to a Sun's boot-prom in order to write a '0' into the UID
:member of one's shell's struct proc?

Yes.  It works a treat.  Similar steps let you do the same thing with DDB
or (presumably, haven't tried) remote gdb.

David




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Alfred Perlstein

* Nicolai Petri <[EMAIL PROTECTED]> [001116 02:37] wrote:
> What's the best approach for a simple web-server(never more the 10 clients)
> ? Is it using pthread and a thread per connection . Or to make a
> non-blocking single thread server. Can people show me some simple examples
> of the 2 techniques ?
> 
> And what's the pro's and con's for the 2 methods ???

Because you want something simple, I would use a thread per connection.
For a more complex/high-perfomance server you'd want to use several
threads using event queues and perhaps external processes for disk
IO.

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: More detail on Deskpro XL6200 NIC (was: Legacy ethernet cards in FreeBSD)

2000-11-16 Thread Bill Paul

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Dear Bill, others,
> 
> I've been working on getting my Deskpros to use their NIC under 4.2, but no
> luck. The problem is as follows: I installed 4.0, and the NIC came up under
> the lnc driver, reports its MAC address and works fine.
> 
[...] 
> In 4.2, the lnc driver still probes and finds the NIC, but does not report
> finding a MAC address, and the NIC remains dead.
[...]
> Compiling a kernel with the pcn driver does not help. Booting a lnc+pcn
> kernel causes the behaviour described above, booting a pcn-only kernel makes
> the NIC show up as an unknown device, vendor 0x1022, device 0x2000.

*ahem* How about compiling a kernel *without* the pcn driver? I want to
know why you didn't consider this combination. (Well, I know why: because
giving me the answer straight away rather than making me drag it out of
you would have been too easy. I would never be that lucky.)

The pcn driver does *not* want this card. It specifically checks for
the device code in the probe routine and rejects cards it doesn't like.
Note that this is *not* the PCI vendor/device ID: the way AMD did it,
the PCI ID is the same for all the PCnet devices. You need to read a
register in I/O space to determine exactly what device this is.

That said, I think I know what the problem is. The pcn driver is probing
the card first and setting it to 32-bit mode. The lnc driver wants the
device to be in 16-bit mode: if it isn't, it won't be able to properly
access any of its registers. This is why reading the card type and MAC
address fails.

Next time, *remove* the pcn device from the kernel config and leave
the lnc driver. That should work. In the meantime, I need to get out
the PCnet manual and check how to put the device back into 16-bit mode
at the end of pcn_probe() so that the lnc driver will play nice with it.

-Bill


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Resolution

2000-11-16 Thread Jamie Heckford

How would i go about changing the resolution of my vt??

Im fed up with the 320 x X mode it uses, and want to maybe get it up to
1024x768.

Any ideas anyone?

Thanks,

-- 
Jamie Heckford
Chief Network Engineer
Psi-Domain - Innovative Linux Solutions. Ask Us How.

===
email: [EMAIL PROTECTED]
web: http://www.psi-domain.co.uk/

tel:   +44 (0)1737 789 246
fax:   +44 (0)1737 789 245
mobile:+44 (0)7779 646 529
===


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Resolution

2000-11-16 Thread Dan Nelson

In the last episode (Nov 16), Jamie Heckford said:
> How would i go about changing the resolution of my vt??
> 
> Im fed up with the 320 x X mode it uses, and want to maybe get it up to
> 1024x768.

Console screens aren't pixel-based; they're character-cell based.  The
default console is 80x25, which is really 720x400 pixels if you want to
keep track.  If you want more lines/columns on the console, see the
vidcontrol manpage.

-- 
Dan Nelson
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: More detail on Deskpro XL6200 NIC (was: Legacy ethernet cards in FreeBSD)

2000-11-16 Thread Bill Paul

Well this sucks. According to the manual, once you select 32-bit mode,
the only way to get the chip back to 16-bit mode is a hardware reset.
I suppose the quick fix for now is to not let if_pcn switch the chip
into 32-bit mode during the probe routine. Please try the patch for
if_pcn.c included with this message. It should fix things so if you
have both the pcn and lnc drivers in your kernel, the lnc driver will
attach properly.

I'm cc'ing this to jkh for his approval to have this patch added to
the -stable tree in time for 4.2-RELEASE.

-Bill


*** if_pcn.c.orig   Thu Nov  2 16:37:45 2000
--- if_pcn.cThu Nov 16 11:48:43 2000
***
*** 110,115 
--- 110,116 
  };
  
  static u_int32_t pcn_csr_read __P((struct pcn_softc *, int));
+ static u_int16_t pcn_csr_read16   __P((struct pcn_softc *, int));
  static void pcn_csr_write __P((struct pcn_softc *, int, int));
  static u_int32_t pcn_bcr_read __P((struct pcn_softc *, int));
  static void pcn_bcr_write __P((struct pcn_softc *, int, int));
***
*** 203,208 
--- 204,217 
return(CSR_READ_4(sc, PCN_IO32_RDP));
  }
  
+ static u_int16_t pcn_csr_read16(sc, reg)
+   struct pcn_softc*sc;
+   int reg;
+ {
+   CSR_WRITE_2(sc, PCN_IO16_RAP, reg);
+   return(CSR_READ_2(sc, PCN_IO16_RDP));
+ }
+ 
  static void pcn_csr_write(sc, reg, val)
struct pcn_softc*sc;
int reg;
***
*** 401,410 
mtx_init(&sc->pcn_mtx,
device_get_nameunit(dev), MTX_DEF);
PCN_LOCK(sc);
!   pcn_reset(sc);
!   chip_id = pcn_csr_read(sc, PCN_CSR_CHIPID1);
chip_id <<= 16;
!   chip_id |= pcn_csr_read(sc, PCN_CSR_CHIPID0);
bus_release_resource(dev, PCN_RES,
PCN_RID, sc->pcn_res);
PCN_UNLOCK(sc);
--- 410,429 
mtx_init(&sc->pcn_mtx,
device_get_nameunit(dev), MTX_DEF);
PCN_LOCK(sc);
!   /*
!* Note: we can *NOT* put the chip into
!* 32-bit mode yet. The lnc driver will only
!* work in 16-bit mode, and once the chip
!* goes into 32-bit mode, the only way to
!* get it out again is with a hardware reset.
!* So if pcn_probe() is called before the
!* lnc driver's probe routine, the chip will
!* be locked into 32-bit operation and the lnc
!* driver will be unable to attach to it.
!*/
!   chip_id = pcn_csr_read16(sc, PCN_CSR_CHIPID1);
chip_id <<= 16;
!   chip_id |= pcn_csr_read16(sc, PCN_CSR_CHIPID0);
bus_release_resource(dev, PCN_RES,
PCN_RID, sc->pcn_res);
PCN_UNLOCK(sc);


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: RTP as system calls.

2000-11-16 Thread Daniel C. Sobral

"Yonny Cardenas B." wrote:
> 
> I have some questions:
> 
> 1) Can I call functions level's user into kernel, as socket() or
> calloc() ?

No.

> 2) How must I use the global variable "errno" for value
> returned for system calls ? Is sufficient with  #include  ?

You are not calling system calls from inside the kernel, and you are
also not using errno like you would from userland.

-- 
Daniel C. Sobral(8-DCS)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

He has been convicted of criminal possession of a clue with intent to
distribute.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PPPoE w/ nat auto fragmentation hack? (use tcpmssd port)

2000-11-16 Thread Brian Somers

> > ppp will run programs as the user id that invoked ppp rather than
> > using the effective user id (ie, it runs things as *you*, not *root*).
> 
> Mmm-mmh. In my case, since ppp is started at boot time, the only user that
> ever invokes it is root, hence the tcpmssd thingy is run as root. As
> confirmed by the multiple "ps" I ran: euid == ruid == svguid == 0.
> 
> 
> > A good ``first step'' is to run
> >   ! sh -c "/usr/local/bin/tcpmssd -p 12345 -i INTERFACE >/tmp/log 2>&1"
> > so that you can get to see any error messages - ppp redirects I/O to
> 
> Yup, tried that, here's what I get:
> 
>  start ***
> Wed Nov 15 13:30:12 PST 2000
> id says: uid=0(root) gid=0(wheel) groups=0(wheel)
> HOME=/
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
> 01001 divert 1234 tcp from any to any out xmit tun0 setup
> 
> The rule gets inserted, tcpmssd runs as root, and I feel like a dummy. Any
> other ideas?
> 
> Thanks for the help Brian,

I'm not sure what the problem could be - can you confirm that 
everything's seen if you divert everything ?

> --Renaud
> 
> 
> 
> - Original Message -
> From: Brian Somers <[EMAIL PROTECTED]>
> To: Renaud Waldura <[EMAIL PROTECTED]>
> Cc: Brian Somers <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Wednesday, November 15, 2000 4:32 PM
> Subject: Re: PPPoE w/ nat auto fragmentation hack? (use tcpmssd port)
> 
> 
> > > Maybe I'm just being boneheaded, but...
> > >
> > > >   ! sudo ipfw add 4 divert 12345 all from any to any via INTERFACE
> > > >   ! sudo /usr/local/bin/tcpmssd -p 12345 -i INTERFACE
> > >
> > > I was under the (tested & confirmed) impression that programs executed
> by
> > > ppp are run under uid 0. Eg. I don't use "sudo" but the ipfw rule is
> added
> > > anyway, and tcpmssd is run as root.
> > >
> > > But maybe a sudo environment brings something else? That could explain a
> lot
> > > right there.
> > >
> > > --Renaud
> >
> > ppp will run programs as the user id that invoked ppp rather than
> > using the effective user id (ie, it runs things as *you*, not *root*).
> >
> > AFAIK, sudo will not muck about with your environment
> >
> > A good ``first step'' is to run
> >
> >   ! sh -c "/usr/local/bin/tcpmssd -p 12345 -i INTERFACE >/tmp/log 2>&1"
> >
> > so that you can get to see any error messages - ppp redirects I/O to
> > /dev/null by default.

-- 
Brian <[EMAIL PROTECTED]>
     
Don't _EVER_ lose your sense of humour !




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



compiling X apps

2000-11-16 Thread Jamie Heckford

Very sorry for posting such a dumb question, but since I cvs'upd something
weird seems to have happened.

I am using this to compile my X app (which just uses Xlib.h at the mo)

gcc -L/usr/X11R6/include -o test test.cc

but it cannot locate Xlib.h?!!

Any suggestions?

Thanks.

-- 
Jamie Heckford
Chief Network Engineer
Psi-Domain - Innovative Linux Solutions. Ask Us How.

===
email: [EMAIL PROTECTED]
web: http://www.psi-domain.co.uk/

tel:   +44 (0)1737 789 246
fax:   +44 (0)1737 789 245
mobile:+44 (0)7779 646 529
===


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: compiling X apps

2000-11-16 Thread Brian Reichert

On Thu, Nov 16, 2000 at 09:47:51PM +, Jamie Heckford wrote:
> Very sorry for posting such a dumb question, but since I cvs'upd something
> weird seems to have happened.
> 
> I am using this to compile my X app (which just uses Xlib.h at the mo)
> 
> gcc -L/usr/X11R6/include -o test test.cc
  -I/usr/X11R6/include

'-L' is for directories of libriaries.

> but it cannot locate Xlib.h?!!
> 
> Any suggestions?
> 
> Thanks.
> 
> -- 
> Jamie Heckford
> Chief Network Engineer
> Psi-Domain - Innovative Linux Solutions. Ask Us How.

'Innovative Linux'? :)

> ===
> email: [EMAIL PROTECTED]
> web:   http://www.psi-domain.co.uk/
> 
> tel: +44 (0)1737 789 246
> fax: +44 (0)1737 789 245
> mobile:  +44 (0)7779 646 529
> ===

-- 
Brian 'you Bastard' Reichert<[EMAIL PROTECTED]>
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA Intel architecture: the left-hand path


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: compiling X apps

2000-11-16 Thread Alex Belits

On Thu, 16 Nov 2000, Jamie Heckford wrote:

> Very sorry for posting such a dumb question, but since I cvs'upd something
> weird seems to have happened.
> 
> I am using this to compile my X app (which just uses Xlib.h at the mo)
> 
> gcc -L/usr/X11R6/include -o test test.cc
> 
> but it cannot locate Xlib.h?!!
> 
> Any suggestions?

  1. man xmkmf
  2. -I /usr/X11R6/include

-- 
Alex

--
 Excellent.. now give users the option to cut your hair you hippie!
  -- Anonymous Coward



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Bakul Shah

> What's the best approach for a simple web-server(never more the 10 clients)
> ? Is it using pthread and a thread per connection . Or to make a
> non-blocking single thread server. Can people show me some simple examples
> of the 2 techniques ?
> 
> And what's the pro's and con's for the 2 methods ???

The simplest solution is to just fork a new process on
accepting a new connection.  A sample implementation is
included at the end.  This solution doesn't scale too well as
a process is quite heavy weight and uses much more resources
than the other two solutions.  One variation avoids the cost
of fork/exit per connection.  The connection accepting
process passes the new file descriptor in a message to a free
server process.  The acceptor creates server threads as
needed and the server threads can be made to exit when they
are idle for a while.

The thread per connection solution is also quite simple and
significantly more efficient that process per connection
since a thread context switch is a lot cheaper than a process
context switch.  But you need to deal with concurrency issues
if you have to share a bunch of state and your threads can be
preempted.  With this and the next solution you can also run
into file descriptor limits.  I don't have an example I can
show you.

A non-blocking single thread server is likely to be more
portable than the pthread solution.
See
http://www.bitblocks.com/src/select-test.c
for an example.

The basic problem here is what to do if deep down in some
function you need to wait for some response from a client.
As an example, consider the case where function A is called
when a new connection comes in.  A calls B and B calls C and
C wants to block.  You have no choice but to implement this
as a state machine and break functions B, C in B1, B2, C1 and
C2 and carry around appropriate state.  So you have to take
something like

A(int fd) { // called on a new connection
...
B(fd);
...
}

B(int fd) {
...
C(fd);
...
}

C(int fd) {
...
read(fd, buf, len);
...
}

and change it to

A(int fd, Context* c) { // called on a new connection
switch (c->state) {
case init:
...
B1(fd, c);
break;
case more:
B2(fd, c);
...
}
}

B1(int fd, Context* c) {
...
C1(fd, c);
}

B2(int fd, Context* c) {
C2(fd, c);
...
}

C1(int fd, Context* c) {
...
c->state = more;
}

C2(int fd, Context* c) {
len = read(fd, bufptr, len);
if (read enough)
c->state = init;
else
update bufptr
...
}

If you have a complex interaction with the client, the number
of states can explode.  Worse, such interactions may get
added as the application evolves so you are forced to do a
conversion like the one shown above.  In effect here you are
implementing threading in a application specific way and the
c->state variable has a role analogous to a program counter
of a thread.

At the same time concurrency issues are easier to deal with
than the pthreads case since this is cooperative
multithreading.

In my (somewhat dated) experience this solution was a bit
more efficient than the pthreads version but significantly
more complex -- this situation may have changed in pthreads'
favor.  Also, typically here you require much less memory to
store a connection's state than what you spend with a pthread
-- an issue if you have thousands of connections.  If only a
few are active at a time this single thread select loop
solution is a perfectly usable solution and uses the least
resources.

You didn't ask for this but note that for handling a very
large number of clients (thousands to millions) you have to
use a combination of techniques to deal with various resource
limits.  For example, you can push timeconsuming diskio
requests to separate threads or ever separate machines.
You can use multiple processes to deal with file descriptor
limits and so on.

-- bakul

/* A simple fork-a-server-on-accepting-a-connection solution */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

void
reaper(int ignore)
{
int status;
wait(&status);
} 

void
process_request(int fd)
{
char buffer[11];
int len = sprintf(buffer, "%d\n", getpid());
write(fd, buffer, len);
}

int
main(int argc, char** argv)
{
u_short port = argc > 1? strtoul(argv[1], 0, 0) : 1234;
int s = socket(PF_INET, SOCK_STREAM, 0);
int one = 1;
   

Re: "iowait" CPU state

2000-11-16 Thread Terry Lambert

> Ummm, how about a situation where you have a steadily
> increasing work load (more customers?) and want to have
> decent statistics of your servers to determine exactly
> what parts to upgrade and/or if you need to put extra
> machines into service?

Two words: capacity planning.

Terry Lambert
[EMAIL PROTECTED]
---
Any opinions in this posting are my own and not those of my present
or previous employers.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: "iowait" CPU state

2000-11-16 Thread Rik van Riel

On Thu, 16 Nov 2000, Terry Lambert wrote:

> > Ummm, how about a situation where you have a steadily
> > increasing work load (more customers?) and want to have
> > decent statistics of your servers to determine exactly
> > what parts to upgrade and/or if you need to put extra
> > machines into service?
> 
> Two words: capacity planning.

For which you really want all the useful
statistics the OS could give you.

(including maybe the %iowait one)

cheers,

Rik
--
"What you're running that piece of shit Gnome?!?!"
   -- Miguel de Icaza, UKUUG 2000

http://www.conectiva.com/   http://www.surriel.com/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread FengYue


On Thu, 16 Nov 2000, Bakul Shah wrote:
->The simplest solution is to just fork a new process on
->accepting a new connection.  A sample implementation is

why not just bind to the port and then spawn off some processes (like 20
in his case) to do the accept(), once the accept() returns successfully just
take care of the request, close the connection and then goes back 
to accept().  Simple, easy, and even scales pretty well.  Since
it's freebsd, you even don't need to worry about putting a lock
around the accept() call.  



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Bakul Shah

> why not just bind to the port and then spawn off some processes (like 20
> in his case) to do the accept(), once the accept() returns successfully just
> take care of the request, close the connection and then goes back 
> to accept().  Simple, easy, and even scales pretty well.  Since
> it's freebsd, you even don't need to worry about putting a lock
> around the accept() call.  

Yes, this is definitely simpler and preferable when servicing
a small number of concurrent requests.  But you have to spawn
off as many processes as the worst case number of concurrent
requests you want to service since while all the processes
are busy servicing, additional connections are not being
accepted (after the listen backlog is exhausted).  By using
one process to accept connections, hand out requests and
create processes as needed and by allowing idle processes to
exit, you can dynamically adjust the number of server
processes (e.g.  depending on some user input or system load
or resource use or day of time or whatever).  You can also
reject additional requests more intelligently (or redirecting
them elsewhere) as opposed to not just accepting new
connections.  So this is more flexible at a small increase in
complexity.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread FengYue


On Thu, 16 Nov 2000, Bakul Shah wrote:

->Yes, this is definitely simpler and preferable when servicing
->a small number of concurrent requests.  But you have to spawn
->off as many processes as the worst case number of concurrent
->requests you want to service since while all the processes
->are busy servicing, additional connections are not being
->accepted (after the listen backlog is exhausted).  By using

Well, with some additional coding, the parent process could easily
monitor how many child processes are being used at a given time (like
using mmap() to create a shared memory region and have the
child process increases the busy_count...etc)
and then to decide if it needs to spawn off some more processes into
the pool based on the percentpage of
number_of_busy_processes/total_processes_in_the_pool.  Just
like the way apache does it I guess.  And, ofcoz, I agree that
there are some performance impact if too many processes blocking on the
accept() call.

But then again, we're just talking about an easy solution for a webserver
that only wants to handle no more than 15 clients at any given time:)




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Multithreaded tcp-server or non-blocking ?

2000-11-16 Thread Alfred Perlstein

* FengYue <[EMAIL PROTECTED]> [001116 16:15] wrote:
> 
> On Thu, 16 Nov 2000, Bakul Shah wrote:
> 
> ->Yes, this is definitely simpler and preferable when servicing
> ->a small number of concurrent requests.  But you have to spawn
> ->off as many processes as the worst case number of concurrent
> ->requests you want to service since while all the processes
> ->are busy servicing, additional connections are not being
> ->accepted (after the listen backlog is exhausted).  By using
> 
> Well, with some additional coding, the parent process could easily
> monitor how many child processes are being used at a given time (like
> using mmap() to create a shared memory region and have the
> child process increases the busy_count...etc)
> and then to decide if it needs to spawn off some more processes into
> the pool based on the percentpage of
> number_of_busy_processes/total_processes_in_the_pool.  Just
> like the way apache does it I guess.  And, ofcoz, I agree that
> there are some performance impact if too many processes blocking on the
> accept() call.

Actually FreeBSD uses wakeup_one() for accept(), the only problem
is when your server must wait on more than one port/IP, then you
need to use select(), however when many processes are selecting
on the same descriptor it kills performance, that's why things
like apache use semaphores or file locks instead of select.

> But then again, we're just talking about an easy solution for a webserver
> that only wants to handle no more than 15 clients at any given time:)

Yes, it may be overkill. :)

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



new kld style

2000-11-16 Thread Mark Santcroos

Hi,

While implementing a module based on /usr/share/examples/cdev???
I noticed that after loading it I get a warning that originates from
kern/kern_linker.c telling me that I'm using the old kld style. [This all
on -CURRENT]

Can you please point me to the right direction for the "new" style. Or
explain me if I'm missing something :-)
[or even tell me that I should not worry about this]


Regards,

Mark

-- 
Mark Santcroos  RIPE Network Coordination Centre

PGP KeyID: 1024/0x3DCBEB8D 
PGP Fingerprint: BB1E D037 F29D 4B40 0B26  F152 795F FCAB 3DCB EB8D


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: looking for kernel hacking info

2000-11-16 Thread Wes Peters

Paonia Ezrine wrote:
> 
> > On Tuesday, 14 November 2000 at 16:32:49 -0500, Paonia Ezrine wrote:
> > > I am looking for info on programing in kernel land. System calls, howto's
> > > etc. I have not found anything that realy covers this stuff any and all
> > > help would be welcomed!
> >
> > The system calls are described in section 2 of the manual.
> >
> > Greg
> thanks. do you mean handbook?

No.  On a FreeBSD system, look in /usr/share/man/man2.  See all those files?
Those are the man pages.  You can access them with the "man" command.

-- 
"Where am I, and what am I doing in this handbasket?"

Wes Peters Softweyr LLC
[EMAIL PROTECTED]   http://softweyr.com/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: looking for kernel hacking info

2000-11-16 Thread Wes Peters

Greg Lehey wrote:
> 
> On Wednesday, 15 November 2000 at 10:08:45 +, visi0n wrote:
> >
> >   The THC have a documentation about freebsd kernel space.
> >
> >   packetstorm.securify.com/groups/thc/bsdkern.htm
> 
> Repeating the full URL for the benefit of mutt users, this is
> http://packetstorm.securify.com/groups/thc/bsdkern.htm
> 
> This is an interesting document.  It describes how to insert a Trojan
> into the FreeBSD kernel When it came out, we discussed it and decided
> that it would be of no danger to a properly secured system.  On the
> other hand, the documentation is relatively well done.  We should
> really import it.

Ah, yes, handbook section 23: "FreeBSD for the Ethically Challenged"

;^)

-- 
"Where am I, and what am I doing in this handbasket?"

Wes Peters Softweyr LLC
[EMAIL PROTECTED]   http://softweyr.com/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: ntop, worlds greatest network monitor, no go on FreeBSD (fwd)

2000-11-16 Thread Stanley Hopcroft

-- Forwarded message --
Date: Thu, 16 Nov 2000 17:20:11 -0800 (PST)
From: FengYue <[EMAIL PROTECTED]>
To: Stanley Hopcroft <[EMAIL PROTECTED]>
Subject: Re: ntop, worlds greatest network monitor, no go on FreeBSD


you may consider copying this message to [EMAIL PROTECTED]

On Thu, 16 Nov 2000, Stanley Hopcroft wrote:

->Dear Ladies and Gentlemen,
->
->I am writing to ask for someone to provide advice to the ntop project
->(http://www.ntop.org) on porting to FreeBSD.
->
->There are a number of problems with ntop (1.3.2 26th October) on
->FreeBSD (eg Mr Petri's letter of a few weeks ago) among them that when
->it's built with pthread support (-pthread), it uses all of the CPU
->(built without pthread support, it behaves). 
->
->The problems are manifested on FreeBSD 4.x.
->
->ntop is able to use threads on many other platforms.
->
->ntop is a wonderful monitor. If you have ever wanted RMON2 like ability
->in software with a browser interface, ntop is for you.
->
->There is a port of ntop (for 1.1) but it displays the same CPU hogging
->behaviour as the later version. 
->
->There has been no response from the ntop FreeBSD port mailing list. 
->
->Thank you.
->
->Yours sincerely,
->
->
->S Hopcroft
->
->Network Specialist
->IP Australia
->
->+61 2 6283 3189
->+61 2 6281 1353 FAX
->
->
->
->To Unsubscribe: send mail to [EMAIL PROTECTED]
->with "unsubscribe freebsd-isp" in the body of the message




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: compiling X apps

2000-11-16 Thread Kris Kennaway

On Thu, Nov 16, 2000 at 09:47:51PM +, Jamie Heckford wrote:
> Very sorry for posting such a dumb question, but since I cvs'upd something
> weird seems to have happened.
> 
> I am using this to compile my X app (which just uses Xlib.h at the mo)
> 
> gcc -L/usr/X11R6/include -o test test.cc
> 
> but it cannot locate Xlib.h?!!
> 
> Any suggestions?

Please restrict your questions of this level to the
[EMAIL PROTECTED] mailing list in future - they are
off-topic for -hackers. Thanks.

Kris

 PGP signature