Re: from number to power of two

1999-08-22 Thread John-Mark Gurney

Mark Murray scribbled this message on Aug 22:
> > Does anyone know an inexpensive algorithm (O(1)) to go from an number to
> > the next (lower or higher) power of two.
> > 
> > 1   -> 1
> > 2,3 -> 2
> > 4,5,6,7 -> 4
> > 8,9,10,11,12,13,14,15   -> 8
> > etc.
> > 
> > So %1101 should become either %1 or %1000.
> 
> Shift a bit until it becomes greater than (or less than) the number
> in question.

ummm, didn't you read his post?? he wanted a O(1) routine, NOT a O(n)
routine...

-- 
  John-Mark Gurney  Voice: +1 541 684 8449
  Cu Networking   P.O. Box 5693, 97405

  "The soul contains in itself the event that shall presently befall it.
  The event is only the actualizing of its thought." -- Ralph Waldo Emerson


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



watching defects on scsi disks...

1999-08-22 Thread John-Mark Gurney

I was wondering if someone would like to clean up a bit of shell scripting
I wrote to attach a report of the defect list to the daily output... it
works great so far and thought I might as well share this w/ the rest of
people...

once it gets cleaned up, I have no problems w/ committing it to the tree,
it's just kinda ugly right now...

bak=/var/backups
echo ""
echo ""
echo "checking disks for defects:"
for i in `camcontrol devlist | awk '/(da|sd)/ { if (match($0, "(da|sd)[[:digit:]]+") 
!= 0) { diskname =  substr($0, RSTART, RLENGTH); match(diskname, "[[:digit:]]+"); 
print substr(diskname, RSTART, RLENGTH) } }' | sort -u`; do
if [ -f ${bak}/da${i}.glist ]; then
mv ${bak}/da${i}.glist ${bak}/da${i}.glist.bak
fi
echo -n "da${i}: "
camcontrol defects -u $i -f phys -G 2>&1 > ${bak}/da${i}.glist
if [ -f ${bak}/da${i}.glist.bak ]; then
if ! cmp -s ${bak}/da${i}.glist ${bak}/da${i}.glist.bak; then
diff ${bak}/da${i}.glist.bak ${bak}/da${i}.glist
fi
fi
done

-- 
  John-Mark Gurney  Voice: +1 541 684 8449
  Cu Networking   P.O. Box 5693, 97405

  "The soul contains in itself the event that shall presently befall it.
  The event is only the actualizing of its thought." -- Ralph Waldo Emerson


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



Re: from number to power of two

1999-08-22 Thread Nick Hibma


It seems that all the solutions are too generic and slow. As I only have
to check the numbers 0-32 (actually 1-32), a block of if statements is
almost as fast as a table look up in 33 elements.

Cheers,

Nick


On Sun, 22 Aug 1999, Mark Murray wrote:

> > Does anyone know an inexpensive algorithm (O(1)) to go from an number to
> > the next (lower or higher) power of two.
> > 
> > 1   -> 1
> > 2,3 -> 2
> > 4,5,6,7 -> 4
> > 8,9,10,11,12,13,14,15   -> 8
> > etc.
> > 
> > So %1101 should become either %1 or %1000.
> 
> Shift a bit until it becomes greater than (or less than) the number
> in question.
> 
> M
> --
> Mark Murray
> Join the anti-SPAM movement: http://www.cauce.org
> 
> 

-- 
e-Mail: [EMAIL PROTECTED]



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



select/poll implementation

1999-08-22 Thread Jay Nordwick

I had always wondered how select/poll worked (actually see the end of the
mail to see the broader question), so I pulled up select() and family
and started reading and chasing stuff around.  I think that I fully
understand (much praise to whoever wrote most of that, it was incredibly
easy to read) everything from sys_generic.c.

I just need someone to clear up a couple things:

1) It seems that all select (and poll) calls wait on the same
   condition variable (selwait), so when you wake up on select/poll
call, you wake them all up.  (selwakeup() seems to call wake()
on selwait, but then hunts for a specific process to make runnable(),
I'm confused).

2) Where does the struct sockbuf -> struct selinfo sb_sel get filled
   in?  I see it passed around, but I do not see select setting it
before it tsleeps() on selwait.


thanks
-jason

P.S., Specifically, I was porting a threaed win32 program to UNIX and pthreads.
The one big problem is that there is some win32 event handling code that
waits for events (a glorified condition variable).  There two procedures
that I have to implement are called WaitForSingleEvent() and
WaitForMultipleEvents().  Okay, waiting for a single event is easy to
implement, but waiting for any of multiple events seems more difficult.
I thought to go see how select()/poll() did it, since it did something
similar.




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



Re: from number to power of two

1999-08-22 Thread Daniel C. Sobral

John-Mark Gurney wrote:
> 
> > Shift a bit until it becomes greater than (or less than) the number
> > in question.
> 
> ummm, didn't you read his post?? he wanted a O(1) routine, NOT a O(n)
> routine...

That technique is O(ln(n)), where n is the number in question.

Frankly, for numbers up to 32, a table will wield the best results,
and might actually be smaller than some of the suggestions given so
far.

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

- Come on.
- Where are we going?
- To get what you came for.
- What's that?
- Me.


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



Re: IDE quirk in 3.2-STABLE kernel ?

1999-08-22 Thread Daniel C. Sobral

Chris wrote:
> 
> I am glad to hear from Soren that this 'misconfiguration' will be
> supported in 4.0
> As always when a misconfiguration (read 'not to spec') is used enough
> then it quickly becomes somewhat of a de facto standard.

Old message, but still in need for reply.

Yeah, like isa shared irq's which are no longer supported by
Windows, or pcmcia card removal without previous deactivation which
is no longer supported by Windows, but were all "de facto"
standards.

What happens is that these "de facto" standards usually work only by
accident, only with certain hardware configurations, only with
certain loads, and/or only if the operating system adheres to
certain restrictions (like not being truly multitasking).

FreeBSD's main target is servers. Sure, we do care about desktop,
despite the common claim that we leave that to Linux. But the *main*
target is servers, and if supporting a "de facto standard" will
detract from support for server configurations, we will *not*
support it.

Alas, in most case is just a matter of making options for buggy
hardware/bios/whatever. But, again, people working on FreeBSD is
most likely to devote their time to making *good* hardware work than
making bad hardware work. And the same applies for the case above.

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

- Come on.
- Where are we going?
- To get what you came for.
- What's that?
- Me.



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



Re: from number to power of two

1999-08-22 Thread Peter Dufault

> It seems that all the solutions are too generic and slow. As I only have
> to check the numbers 0-32 (actually 1-32), a block of if statements is
> almost as fast as a table look up in 33 elements.

I doubt it - use the table for a small fixed size set then
use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0".
The possible inline ffs is in machine/cpufunc.h

ffs() is fundamental to scheduling queues and cryptography and
should have attention paid to it.  As Warner said, it could be
a single instruction on some architectures.

Peter

-- 
Peter Dufault ([EMAIL PROTECTED])   Realtime development, Machine control,
HD Associates, Inc.   Safety critical systems, Agency approval


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



Re: from number to power of two

1999-08-22 Thread Kazufumi-MIT-Mitani

 "Daniel C. Sobral" <[EMAIL PROTECTED]> wrote

> That technique is O(ln(n)), where n is the number in question.
> 
> Frankly, for numbers up to 32, a table will wield the best results,
> and might actually be smaller than some of the suggestions given so
> far.

Counting n as bit, it is O(n) :p

Unrolling the loop,

if(n<=2^0) 2^0
else if(n<=2^1) 2^1
else if(n<=2^2) 2^2
else if(n<=2^3) 2^3
   :
   :
else if(n<=2^31) 2^31

is suitable for this problem?

---
//mit



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



Re: from number to power of two

1999-08-22 Thread Nick Hibma


Unfortunately the kernel is compiled with -O which does not include
inlining (dunno about explicit inlining, but don't think so).

Nick

On Sun, 22 Aug 1999, Peter Dufault wrote:

> > It seems that all the solutions are too generic and slow. As I only have
> > to check the numbers 0-32 (actually 1-32), a block of if statements is
> > almost as fast as a table look up in 33 elements.
> 
> I doubt it - use the table for a small fixed size set then
> use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0".
> The possible inline ffs is in machine/cpufunc.h
> 
> ffs() is fundamental to scheduling queues and cryptography and
> should have attention paid to it.  As Warner said, it could be
> a single instruction on some architectures.
> 
> Peter
> 
> -- 
> Peter Dufault ([EMAIL PROTECTED])   Realtime development, Machine control,
> HD Associates, Inc.   Safety critical systems, Agency approval
> 
> 

-- 
e-Mail: [EMAIL PROTECTED]



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



Re: from number to power of two

1999-08-22 Thread Tommy Hallgren

--- Kazufumi-MIT-Mitani <[EMAIL PROTECTED]> skrev:
>  "Daniel C. Sobral" <[EMAIL PROTECTED]> wrote
> 
> > That technique is O(ln(n)), where n is the number in question.
> > 
> > Frankly, for numbers up to 32, a table will wield the best results,
> > and might actually be smaller than some of the suggestions given so
> > far.
> 
> Counting n as bit, it is O(n) :p

No it isn't. You're only looping a maximum of 32 times, not 2^32 times.

> Unrolling the loop,
> 
> if(n<=2^0) 2^0
> else if(n<=2^1) 2^1
> else if(n<=2^2) 2^2
> else if(n<=2^3) 2^3
>:
>:
> else if(n<=2^31) 2^31
> 
> is suitable for this problem?

IMHO, the best solution so far, if a lookup table isn't suitable, is the binary
search version that someone posted.

Regards, Tommy

===
Tommy Hallgren
Briljantg. 31, SE-421 49, Göteborg
Tel.: 0709 - 312 404 (GSM)
Tel.: 031 - 47 65 28 (Home)
__
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com



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



font edit tools

1999-08-22 Thread Alexey M. Zelkin

hi,

Which tools can be used to edit syscons fonts ?

Any references are welcome!

-- 
Sincerely Yours,   | [EMAIL PROTECTED]  (primary)
Alexey Zelkin  | [EMAIL PROTECTED] (home)
   | ICQ: #6196584,  FIDO: 2:460/12.26


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



Re: font edit tools

1999-08-22 Thread Sergey Babkin

Alexey M. Zelkin wrote:
> 
> hi,
> 
> Which tools can be used to edit syscons fonts ?

Any of the tools you use to edit the DOS fonts.
My favorite one it Evafont by Pete Kvitek. But
there were a lot of tools floating around.

-SB


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



Re: Async NFS exports?

1999-08-22 Thread Doug Rabson

On Fri, 20 Aug 1999, Matthew Dillon wrote:

> :> Just to be clear... I am wondering if mounting (on the NFS _server_) a
> :> partition (that is exportable) as async will have any performance 
> :> benefits to the NFS clients?
> :
> :As a first guess, probably not unless you have a large number of active
> :clients.  Any modern hard disc will outperform ethernet/fast ethernet,
> :especially for larger read/writes.  For large numbers of smaller
> :operations, or when there is a large number of simultaneous outstanding
> :requests from clients, maybe.  I'd say watch the disc itself (iostat is
> :your friend), and if it's pegged (especially large numbers of tps) async
> :might buy you some increase.
> :-- 
> :Matthew Fuller (MF4839) |[EMAIL PROTECTED]
> 
> Not much if at all, whether you have a large number of clients or not,
> at least if you are using NFSv3 mounts.
> 
> The reason is due to the way NFSv3 issues writes.  NFSv3 issues a 
> write but no longer assumes that the write has been synced to the 
> server's disk as of when the reply comes back.  Instead it keeps the
> buffer around and does a later commit rpc to do the sync, presumably
> long after the server has already synced the data. 
> 
> So, effectively, all NFSv3 writes are async insofar as the client's 
> buffer cache is able to keep abrest of the write-rate.
> 
> Hmm, interesting.  I see another optimization I can do to fix the
> buffer cache saturation case in CURRENT on the client.  The COMMIT rpc's
> aren't being issued async.

You need to track the return value of the commit so that you can detect
server reboots and sync-write the data again. If you change to async, make
sure that you still keep this part - its essential to the protocol.

--
Doug Rabson Mail:  [EMAIL PROTECTED]
Nonlinear Systems Ltd.  Phone: +44 181 442 9037




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



Re: Async NFS exports?

1999-08-22 Thread Matthew Dillon

:> buffer cache is able to keep abrest of the write-rate.
:> 
:> Hmm, interesting.  I see another optimization I can do to fix the
:> buffer cache saturation case in CURRENT on the client.  The COMMIT rpc's
:> aren't being issued async.
:
:You need to track the return value of the commit so that you can detect
:server reboots and sync-write the data again. If you change to async, make
:sure that you still keep this part - its essential to the protocol.
:
:--
:Doug RabsonMail:  [EMAIL PROTECTED]
:Nonlinear Systems Ltd. Phone: +44 181 442 9037

   These are buffer-cache entities we are talking about here, so they won't 
   go away until NFS tells the system they can go away.  In that respect
   async I/O is no different then sync I/O.  async I/O is simply run
   synchronously from an nfsiod context.

-Matt
Matthew Dillon 
<[EMAIL PROTECTED]>


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



Parallel Video Interfaces

1999-08-22 Thread The Evil Anti-Rick

Is anyone doing any work to support parallel video interfaces like
the Snappy or Gotcha cards? I have Snappy card, and I would like to put
it to use as part of an internal video security system.

--R. Pelletier,
Sys Admin, House Galiagante


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



Re: I2C/SMBus/LPBB

1999-08-22 Thread Nicolas Souchu

On Sat, Aug 21, 1999 at 02:46:51AM -0400, Mike Nowlin wrote:
>
>
>I had sent this message to -stable about a month ago, never heard anything
>-- so am trying it here. 

Hmm lpbb seem to fail completly then...

I have to give it a try. Ask me again if I fail to remember. I'm a bit busy.

Thanks for your attempts.

Nicholas

-- 
[EMAIL PROTECTED] / [EMAIL PROTECTED]
FreeBSD - Turning PCs into workstations - http://www.FreeBSD.org


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



Re: font edit tools

1999-08-22 Thread Ollivier Robert

According to Sergey Babkin:
> Any of the tools you use to edit the DOS fonts.
> My favorite one it Evafont by Pete Kvitek. But
> there were a lot of tools floating around.

I know do the opposite. I modify the font with XmBDFED in BDF format then
generate the syscons font with a small Perl script. A logn time ago I used
Evafont too. Nice program.
-- 
Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- [EMAIL PROTECTED]
FreeBSD keltia.freenix.fr 4.0-CURRENT #73: Sat Jul 31 15:36:05 CEST 1999



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



Re: from number to power of two

1999-08-22 Thread Peter Wemm

Peter Dufault wrote:
> > It seems that all the solutions are too generic and slow. As I only have
> > to check the numbers 0-32 (actually 1-32), a block of if statements is
> > almost as fast as a table look up in 33 elements.
> 
> I doubt it - use the table for a small fixed size set then
> use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0".
> The possible inline ffs is in machine/cpufunc.h
> 
> ffs() is fundamental to scheduling queues and cryptography and
> should have attention paid to it.  As Warner said, it could be
> a single instruction on some architectures.

ffs() works from the wrong direction though.  He needs the MSB, not the LSB.

There is a fls() inline in  though, at least for the x86
family which I think will return the bit number (range: 32 - 1) of the MSB.

So, to get the rounded down (and up) power-of-two value you'd do:

#include 
#include 
#include 

main()
{
int i, down, up;

for (i = 0; i < 65; i++) {
down = i ? (1 << (fls(i) - 1)) : 0;
up = 1 << fls(i);
printf("%d %d %d\n", i, down, up);
}
}

I'm not sure what you want at zero, but the result is:
0  0  1
1  1  2
2  2  4
3  2  4
4  4  8
5  4  8
6  4  8
7  4  8
8  8 16
9  8 16
10 8 16
11 8 16
12 8 16
13 8 16
14 8 16
15 8 16
16 16 32
17 16 32

The << is normally implemented as a barrel shift on most modern CPU's.

The other key trick is (x) & -(x).  That returns the LSB in position, not
the bit number.

ie: 12 & -12 =
  1100
& 0100 (twos complement, in byte form)
= 0100 = 4 = the value of the LSB.

Cheers,
-Peter
--
Peter Wemm - [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]



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



Re: font edit tools

1999-08-22 Thread Dan Nelson

In the last episode (Aug 22), Sergey Babkin said:
> Alexey M. Zelkin wrote:
> > 
> > hi,
> > 
> > Which tools can be used to edit syscons fonts ?
> 
> Any of the tools you use to edit the DOS fonts.
> My favorite one it Evafont by Pete Kvitek. But
> there were a lot of tools floating around.

I like one called Font Mania!; the author doesn't seem to have a web
presence, but an URL is http://jconroy.dragonfire.net/zzt/utilities/Fm.zip

-- 
Dan Nelson
[EMAIL PROTECTED]


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



Re: select/poll implementation

1999-08-22 Thread Nate Williams

> I had always wondered how select/poll worked (actually see the end of the
> mail to see the broader question), so I pulled up select() and family
> and started reading and chasing stuff around.  I think that I fully
> understand (much praise to whoever wrote most of that, it was incredibly
> easy to read) everything from sys_generic.c.

Sean Fagan walked me through the code a couple of years ago, and after
our discussion he decided to submit this to Dr. Dobbs.  The article
should be available in their archives somewhere to explain these things
in some detail, and should answer the questions you have.


Nate


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



Mandatory locking?

1999-08-22 Thread Greg Lehey

I've just found a need for mandatory locking in Vinum, and I'm
wondering how to implement it.  If I understand things correctly, our
fcntl locking doesn't perform mandatory locking, though System V does
if you set the file permissions appropriately.

Questions:

1.  Do we have some form of mandatory locking?  If so, what is it?

2.  Would it make sense to implement System V's fcntl semantics?
They're rather tacky: you set the setgid bit and reset the group
exec bit of the file permissions.

3.  Alternatively (or additionally), would it make sense to have an
additional fcntl function which performs mandatory locking?

I think that it's probably a good idea to implement (3), and also to
do (2), possibly subject to a sysctl knob.

Greg
--
See complete headers for address, home page and phone numbers
finger [EMAIL PROTECTED] for PGP public key


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



Re: from number to power of two

1999-08-22 Thread Brian F. Feldman

On Sun, 22 Aug 1999, Nick Hibma wrote:

> 
> Unfortunately the kernel is compiled with -O which does not include
> inlining (dunno about explicit inlining, but don't think so).
> 
> Nick

-O lets you do explicit inlining, and -O2 enables -finline-functions.
Anyway, I think the simple solution to the problem for this case
is a switch, since GCC creates optimizations nicely with those :)

-- 
 Brian Fundakowski Feldman   /  "Any sufficiently advanced bug is\
 [EMAIL PROTECTED]   |   indistinguishable from a feature."  |
 FreeBSD: The Power to Serve!\-- Rich Kulawiec   /



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



Re: Mandatory locking?

1999-08-22 Thread Matthew Dillon


:Questions:
:
:1.  Do we have some form of mandatory locking?  If so, what is it?

No we don't, unless you count the ad-hoc lockout in the master/slave pty 
interface :-).

:2.  Would it make sense to implement System V's fcntl semantics?
:They're rather tacky: you set the setgid bit and reset the group
:exec bit of the file permissions.

Ugh.  Yuch.  No, nothing to do with permission bits, not for something
this convoluted!

:3.  Alternatively (or additionally), would it make sense to have an
:additional fcntl function which performs mandatory locking?
:
:I think that it's probably a good idea to implement (3), and also to
:do (2), possibly subject to a sysctl knob.
:
:Greg

Well, #3 can't be mandatory if you have to make a fcntl call!  You mean
have one program make a fcntl call that causes other programs to
return an error or block if they try to open that file while the first
program holds an open descriptor?

-Matt
Matthew Dillon 
<[EMAIL PROTECTED]>


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



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey

On Sunday, 22 August 1999 at 17:31:44 -0700, Matthew Dillon wrote:
>
>> Questions:
>> 
>> 1.  Do we have some form of mandatory locking?  If so, what is it?
>
> No we don't, unless you count the ad-hoc lockout in the master/slave pty
> interface :-).
>
>> 2.  Would it make sense to implement System V's fcntl semantics?
>> They're rather tacky: you set the setgid bit and reset the group
>> exec bit of the file permissions.
>
> Ugh.  Yuch.  No, nothing to do with permission bits, not for something
> this convoluted!

I don't like it either, but for compatibility reasons it would make
sense.  That's why I suggested a sysctl knob.

>> 3.  Alternatively (or additionally), would it make sense to have an
>> additional fcntl function which performs mandatory locking?
>> 
>> I think that it's probably a good idea to implement (3), and also to
>> do (2), possibly subject to a sysctl knob.
>
> Well, #3 can't be mandatory if you have to make a fcntl call!

Somehow you need to get a lock.

> You mean have one program make a fcntl call that causes other
> programs to return an error or block if they try to open that
> file while the first program holds an open descriptor?

Correct.  I suppose it's worth discussing what the default should be.
Should they get EAGAIN or block?  Obviously you'd want a way of
specifying which, but there would have to be a default for
non-lock-aware programs.  I think I'd go for blocking; it's less error
prone.

Greg
--
See complete headers for address, home page and phone numbers
finger [EMAIL PROTECTED] for PGP public key


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



What does unp stand for?

1999-08-22 Thread Zhihui Zhang


In file uipc_usrreq.c, there are many routines beginning with unp_. For
example, unp_connect(), unp_bind(), etc. What does unp stand for?  

Thanks. 

--
Zhihui Zhang.  Please visit http://www.freebsd.org
--



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



Re: What does unp stand for?

1999-08-22 Thread Bill Fumerola

On Sun, 22 Aug 1999, Zhihui Zhang wrote:

> In file uipc_usrreq.c, there are many routines beginning with unp_. For
> example, unp_connect(), unp_bind(), etc. What does unp stand for?  


W. Richard Stevens wrote a book Unix Network Programming often refered
to by UNP, which includes his improved versions of socket functions.


The above could be completly wrong.

-- 
- bill fumerola - [EMAIL PROTECTED] - BF1560 - computer horizons corp -
- ph:(800) 252-2421 - [EMAIL PROTECTED] - [EMAIL PROTECTED]  -






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



Re: mmap mapped segment length

1999-08-22 Thread Wes Peters

Matthew Dillon wrote:
> 
> :Now I've got to go figure out what *I've* screwed up.  I fstat the file before
> :mapping it and pass S.st_size as the map length.  Is there any reason why
> :mmap would return non-NULL but map less than the requested size?
> :
> :Scratching my head,
> 
> Note that mmap() returns (void *)-1 when an error occurs, *not* NULL.
> 
> This is because it is legal to mmap at address 0.

Uh, yeah, the program source actually checks against MAP_FAILED.  I do usually
read the man pages when I write code.  ;^)

I found the problem, it was caused by unexpected input.  Doh!  The program is
now working, and is on the 44th (of 78) 60 megabyte input files.  Good thing
the REAL system is a dual PII Xeon 450, huh?  Maybe I should add a -j jobs 
option so I can make sure we use that other processor.  As I/O bound as 
this task is, I'm not sure it would help.

Thanks to everyone who responded, and for the politeness of the responses in
the face of the stupidity of the original question.

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

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


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



Re: What does unp stand for?

1999-08-22 Thread Brian F. Feldman

On Sun, 22 Aug 1999, Bill Fumerola wrote:

> On Sun, 22 Aug 1999, Zhihui Zhang wrote:
> 
> > In file uipc_usrreq.c, there are many routines beginning with unp_. For
> > example, unp_connect(), unp_bind(), etc. What does unp stand for?  
> 
> 
> W. Richard Stevens wrote a book Unix Network Programming often refered
> to by UNP, which includes his improved versions of socket functions.
> 
> 
> The above could be completly wrong.

Actually, I'm pretty sure it standard for Unix network protocol, as in
good old PF_UNIX/PF_LOCAL.

-- 
 Brian Fundakowski Feldman   /  "Any sufficiently advanced bug is\
 [EMAIL PROTECTED]   |   indistinguishable from a feature."  |
 FreeBSD: The Power to Serve!\-- Rich Kulawiec   /



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



Re: from number to power of two

1999-08-22 Thread Bakul Shah

The best I can come up with is this:

/*  kk+1 k
 * given n, return 2  such that 2> n >= 2
 */
inline unsigned long
n2power2(unsigned long n)
{
/* `smear' the highest set bit to the right */
n |= n>>1; n |= n>>2; n |= n>>4; n |= n>>8; n |= n>>16;
/* now n is of the form 0..01..1 */
return n & ~(n>>1);
}

Note that n bit shift is also O(n) on many machines but
usually a machine instruction implements it so this may still
be faster than 5 or 6 compares and branches that you would
need if a binary search was used.  But
n ? 1 << (fls(n)-1) : 0
where fls is inlined may still beat it!

-- bakul


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



Re: Mandatory locking?

1999-08-22 Thread Garrett Wollman

< said:

> Correct.  I suppose it's worth discussing what the default should be.
> Should they get EAGAIN or block?  Obviously you'd want a way of
> specifying which, but there would have to be a default for
> non-lock-aware programs.  I think I'd go for blocking; it's less error
> prone.

I'd be strongly opposed to any sort of mandatory locking.  The whole
notion is unspeakably evil, although this is mitigated somewhat if it
does not apply to processes with appropriate privilege.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
[EMAIL PROTECTED]  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick


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



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey

On Sunday, 22 August 1999 at 22:07:04 -0400, Garrett Wollman wrote:
> < said:
>
>> Correct.  I suppose it's worth discussing what the default should be.
>> Should they get EAGAIN or block?  Obviously you'd want a way of
>> specifying which, but there would have to be a default for
>> non-lock-aware programs.  I think I'd go for blocking; it's less error
>> prone.
>
> I'd be strongly opposed to any sort of mandatory locking.  The whole
> notion is unspeakably evil, although this is mitigated somewhat if it
> does not apply to processes with appropriate privilege.

That's a strange thing to say.  Should we do away with locks in the
kernel too?

Greg
--
See complete headers for address, home page and phone numbers
finger [EMAIL PROTECTED] for PGP public key


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



Re: Mandatory locking?

1999-08-22 Thread Matthew Dillon


:Somehow you need to get a lock.
:
:> You mean have one program make a fcntl call that causes other
:> programs to return an error or block if they try to open that
:> file while the first program holds an open descriptor?
:
:Correct.  I suppose it's worth discussing what the default should be.
:Should they get EAGAIN or block?  Obviously you'd want a way of
:specifying which, but there would have to be a default for
:non-lock-aware programs.  I think I'd go for blocking; it's less error
:prone.
:
:Greg

I dunno, it sounds pretty icky to me.   I would redesign whatever you
are doing that requires mandatory locks to use advisory locks instead.
It can be as simple as a wrapper around whatever program your users are
running that is causing whatever the problem is.

-Matt
Matthew Dillon 
<[EMAIL PROTECTED]>


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



Interesting ssh + X + tcp_wrappers problem

1999-08-22 Thread Doug

I've been doing some housecleaning lately and I finally decided to set up
a one-way ssh authentication from my workstation to my gateway machine. I
set up the ssh keys and that was all good. Then I went to start an X app on
the gateway expecting it to just pop up on the workstation's X display
(happens to be cvsup, but I don't think that's relevant) and I got the
following:

error: Fwd X11 connection from dt010nb9.san.rr.com refused by tcp_wrappers.

I am using natd on the gateway to hook me up to my cable modem. The
hostname is the one that the world sees me as, and is assigned to the
outside interface. I have the inside interface set up as 10.0.0.1, and the
workstation is 10.0.0.2. I have ALL : 10.0.0.2 : allow in /etc/hosts.allow
(and appropriate ipfw filtering set up of course), but I didn't have the
address of the outside interface in there anywhere since I never expected
it would be a problem for the machine to connect to itself. :) 

Now I am not sure if this is an sshd problem, an X problem, a tcp_wrappers
problem, or what have you. I do know that once I put an entry for the
outside interface address in hosts.allow it worked. The only problem I have
with that is that with dhcp that address changes every time someone gets a
wild hair and reboots the dhcp server, and they do that a couple times a
month. This makes one more thing that I have to add to my
"bugger-I-got-another-new-IP" script that I'd prefer to avoid. 

Thoughts, comments, suggestions welcome,

Doug


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



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey

On Sunday, 22 August 1999 at 22:04:38 -0700, Matthew Dillon wrote:
>
>> Somehow you need to get a lock.
>>
>>> You mean have one program make a fcntl call that causes other
>>> programs to return an error or block if they try to open that
>>> file while the first program holds an open descriptor?
>>
>> Correct.  I suppose it's worth discussing what the default should be.
>> Should they get EAGAIN or block?  Obviously you'd want a way of
>> specifying which, but there would have to be a default for
>> non-lock-aware programs.  I think I'd go for blocking; it's less error
>> prone.
>
> I dunno, it sounds pretty icky to me.   I would redesign whatever you
> are doing that requires mandatory locks to use advisory locks
> instead.
>
> It can be as simple as a wrapper around whatever program your users are
> running that is causing whatever the problem is.

I'm accessing a file that any program might want to open.  Redesigning
everything isn't an option.

On Monday, 23 August 1999 at  7:29:32 +0200, Poul-Henning Kamp wrote:
> In message <[EMAIL PROTECTED]>, Greg Lehey writes:
>> On Sunday, 22 August 1999 at 22:52:33 -0400, Garrett Wollman wrote:
>>> < said:
>>>
 That's a strange thing to say.  Should we do away with locks in the
 kernel too?
>>>
>>> Of course not.  Locks in the kernel are actually necessary.
>>
>> So what's unspeakably evil about ensuring that user processes don't
>> tread on each other's feet?  In my specific case, I need to make a
>> Vinum volume inaccessible while rebuilding the parity stripes.  How
>> would you ensure that?  A user process is doing the rebuilding.
>
> Then you give that user-process a magic ioctl to do it with.

That sounds like a kludge to me.

> Why should it be made unavailable ?

So that certain multiple accesses can be done atomically.

> I thought the idea of RAID-5 was that this wasn't needed ?

No, the idea of RAID-5 is that you can tolerate failures.

I'm a little surprised that there's any objection to the concept of
mandatory locking.  In transaction processing, locking is not
optional, and if any process at all can access a file or set of files
without locking, you can't guarantee the database integrity.  Other
OSs have used mandatory locking for decades, and System V has it too.
So far I haven't seen any arguments, let alone valid ones, against
having it in FreeBSD.

Greg
--
See complete headers for address, home page and phone numbers
finger [EMAIL PROTECTED] for PGP public key


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



Re: from number to power of two

1999-08-22 Thread Ollivier Robert

According to Brian F. Feldman:
> -O lets you do explicit inlining, and -O2 enables -finline-functions.

You meant -O3 of course.

   -O3Optimize yet more. This  turns  on  everything  -O2
  does,  along  with  also  turning on -finline-func-
  tions.
-- 
Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- [EMAIL PROTECTED]
FreeBSD keltia.freenix.fr 4.0-CURRENT #73: Sat Jul 31 15:36:05 CEST 1999



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



Re: Mandatory locking?

1999-08-22 Thread Daniel O'Connor


On 23-Aug-99 Greg Lehey wrote:
>  I'm a little surprised that there's any objection to the concept of
>  mandatory locking.  In transaction processing, locking is not
>  optional, and if any process at all can access a file or set of files
>  without locking, you can't guarantee the database integrity.  Other
>  OSs have used mandatory locking for decades, and System V has it too.
>  So far I haven't seen any arguments, let alone valid ones, against
>  having it in FreeBSD.

I think its a good idea, and hey if people object it can always be an option
like ->

option NO_MANDATORY_LOCKING

Phew, that was tough.

---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum

 PGP signature


Re: Mandatory locking?

1999-08-22 Thread Poul-Henning Kamp

In message <[EMAIL PROTECTED]>, Greg Lehey writes:

>> Why should it be made unavailable ?
>
>So that certain multiple accesses can be done atomically.

You don't need that.  You initialize a index to 0, and whenever
the sector with that index is written, you increment it.

At any one time you know that all parityblocks <= your index
are valid.

All you need to do to recover you index then is to have an
ioctl which will read one sector at a time, mark the buffer
dirty write it out again.

I have seen sources for two well-respected RAID-5 products
which do it this way.

>I'm a little surprised that there's any objection to the concept of
>mandatory locking.

Too many of us have had wedged systems because of it I guess...

--
Poul-Henning Kamp FreeBSD coreteam member
[EMAIL PROTECTED]   "Real hackers run -current on their laptop."
FreeBSD -- It will take a long time before progress goes too far!


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



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey

On Monday, 23 August 1999 at  8:47:34 +0200, Poul-Henning Kamp wrote:
> In message <[EMAIL PROTECTED]>, Greg Lehey writes:
>
>>> Why should it be made unavailable ?
>>
>> So that certain multiple accesses can be done atomically.
>
> You don't need that.  You initialize a index to 0, and whenever the
> sector with that index is written, you increment it.
>
> At any one time you know that all parityblocks <= your index
> are valid.

Sure, that's pretty much what I do in the situation you're thinking
about.  But it won't work without locking.  Take a look at
vinumrevive.c and vinumrequest.c.

My real question was more like "OK, I have a situation coming up in
which I need to be able to lock out other processes.  What tools are
available for it".  I don't know yet whether what I end up with can be
solved by this method, but it's nice to know what tools you have.  You
certainly wouldn't want to lock out access to the entire device during
this time.

>> I'm a little surprised that there's any objection to the concept of
>> mandatory locking.
>
> Too many of us have had wedged systems because of it I guess...

Strange, I've probably used it more than anybody here, and I've never
had a wedged system.  Of course, you need to use it appropriately.
'rm' can be a lethal tool :-)

Greg
--
See complete headers for address, home page and phone numbers
finger [EMAIL PROTECTED] for PGP public key


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



ls(1) options affecting -l long format

1999-08-22 Thread Sheldon Hearn


Hi folks,

Chris Costello recently committed (and then backed out at my request) a
change to ls(1) that made -n (numeric ID's instead of names) imply -l
(long format).

The OpenGroup Single UNIX Specification is quite clear on the following
issue: -g, -n and -o all imply -l. Of course, the OpenGroup spec uses -g
for something we don't offer. Our -g is a backward compatibility option.

So my point here relates to -n and -o.

As I mentioned on the PR associated with the addition of the -n
option, taking it to imply -l does nothing but reduce user-interface
flexibility. It prevents me from using this in my .profile

alias ls='ls -n'

to mean

"When I ask for a long listing, show numeric ID's instead of
 names. If I don't ask for a long listing, don't give me one."

As far as I'm concerned, we should _not_ be following the OpenGroup
spec's mandate on this issue. I think that -o and -n should continue to
operate as they do in FreeBSD's and NetBSD's ls, to allow the kind of
flexibility suggested above. Ideally, the OpenGroup spec should change.
:-)

So what's my question? How hard should we be trying to stick to the
OpenGroup spec? Whatever we decide should apply to both -n and -o.

Ciao,
Sheldon.


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



Re: anybody love qsort.c?

1999-08-22 Thread Christopher Seiwald

Archie's mod to qsort:

|  >-   if (swap_cnt == 0) {  /* Switch to insertion sort */
|  >+   if (n <= 32 && swap_cnt == 0) {  /* Switch to insertion sort */

As Akira Wada points out, this eliminates the benefit of the optimization
in the first place, which is to let isort take over if the data is largely
sorted in the first place.

Akira Wada's alternative mod:

| +   pl = (char *)a; pn = (char *)a + (n - 1) * es;
| +   while (pl < pn && cmp(pl, pl + es) <= 0) pl += es;
| +   if (pl >= pn) return;

This is a little more comprehensive, but does throw in an extra pass
of comparisons, which (I'm sure) someone would complain about.

The alteration that I've tried and tested is to have the isort bail
back to qsort if it does more than N swaps.  I put N at 1024, which
worked for my data :).This is almost guaranteed to do no more work
than the current logic, because it it only gives up on the isort when
it has evidence that the isort is doing too much work.

Christopher


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



Re: Mandatory locking?

1999-08-22 Thread Poul-Henning Kamp

In message <[EMAIL PROTECTED]>, Greg Lehey writes:

 Why should it be made unavailable ?
>>>
>>> So that certain multiple accesses can be done atomically.
>>
>> You don't need that.  You initialize a index to 0, and whenever the
>> sector with that index is written, you increment it.
>>
>> At any one time you know that all parityblocks <= your index
>> are valid.
>
>Sure, that's pretty much what I do in the situation you're thinking
>about.  But it won't work without locking.  Take a look at
>vinumrevive.c and vinumrequest.c.

I still don't see the need for mandatory locking, or locking out
user access in general...

>>> I'm a little surprised that there's any objection to the concept of
>>> mandatory locking.
>>
>> Too many of us have had wedged systems because of it I guess...
>
>Strange, I've probably used it more than anybody here, and I've never
>had a wedged system.  Of course, you need to use it appropriately.
>'rm' can be a lethal tool :-)

Well, maybe you were more lucky, I've had my share of troubles, and
I think the very concept stinks... 

--
Poul-Henning Kamp FreeBSD coreteam member
[EMAIL PROTECTED]   "Real hackers run -current on their laptop."
FreeBSD -- It will take a long time before progress goes too far!


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



Re: from number to power of two

1999-08-22 Thread Mark Murray
> Does anyone know an inexpensive algorithm (O(1)) to go from an number to
> the next (lower or higher) power of two.
> 
> 1 -> 1
> 2,3   -> 2
> 4,5,6,7   -> 4
> 8,9,10,11,12,13,14,15 -> 8
> etc.
> 
> So %1101 should become either %1 or %1000.

Shift a bit until it becomes greater than (or less than) the number
in question.

M
--
Mark Murray
Join the anti-SPAM movement: http://www.cauce.org


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread John-Mark Gurney
Mark Murray scribbled this message on Aug 22:
> > Does anyone know an inexpensive algorithm (O(1)) to go from an number to
> > the next (lower or higher) power of two.
> > 
> > 1   -> 1
> > 2,3 -> 2
> > 4,5,6,7 -> 4
> > 8,9,10,11,12,13,14,15   -> 8
> > etc.
> > 
> > So %1101 should become either %1 or %1000.
> 
> Shift a bit until it becomes greater than (or less than) the number
> in question.

ummm, didn't you read his post?? he wanted a O(1) routine, NOT a O(n)
routine...

-- 
  John-Mark Gurney  Voice: +1 541 684 8449
  Cu Networking   P.O. Box 5693, 97405

  "The soul contains in itself the event that shall presently befall it.
  The event is only the actualizing of its thought." -- Ralph Waldo Emerson


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



watching defects on scsi disks...

1999-08-22 Thread John-Mark Gurney
I was wondering if someone would like to clean up a bit of shell scripting
I wrote to attach a report of the defect list to the daily output... it
works great so far and thought I might as well share this w/ the rest of
people...

once it gets cleaned up, I have no problems w/ committing it to the tree,
it's just kinda ugly right now...

bak=/var/backups
echo ""
echo ""
echo "checking disks for defects:"
for i in `camcontrol devlist | awk '/(da|sd)/ { if (match($0, 
"(da|sd)[[:digit:]]+") != 0) { diskname =  substr($0, RSTART, RLENGTH); 
match(diskname, "[[:digit:]]+"); print substr(diskname, RSTART, RLENGTH) } }' | 
sort -u`; do
if [ -f ${bak}/da${i}.glist ]; then
mv ${bak}/da${i}.glist ${bak}/da${i}.glist.bak
fi
echo -n "da${i}: "
camcontrol defects -u $i -f phys -G 2>&1 > ${bak}/da${i}.glist
if [ -f ${bak}/da${i}.glist.bak ]; then
if ! cmp -s ${bak}/da${i}.glist ${bak}/da${i}.glist.bak; then
diff ${bak}/da${i}.glist.bak ${bak}/da${i}.glist
fi
fi
done

-- 
  John-Mark Gurney  Voice: +1 541 684 8449
  Cu Networking   P.O. Box 5693, 97405

  "The soul contains in itself the event that shall presently befall it.
  The event is only the actualizing of its thought." -- Ralph Waldo Emerson


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Nick Hibma

It seems that all the solutions are too generic and slow. As I only have
to check the numbers 0-32 (actually 1-32), a block of if statements is
almost as fast as a table look up in 33 elements.

Cheers,

Nick


On Sun, 22 Aug 1999, Mark Murray wrote:

> > Does anyone know an inexpensive algorithm (O(1)) to go from an number to
> > the next (lower or higher) power of two.
> > 
> > 1   -> 1
> > 2,3 -> 2
> > 4,5,6,7 -> 4
> > 8,9,10,11,12,13,14,15   -> 8
> > etc.
> > 
> > So %1101 should become either %1 or %1000.
> 
> Shift a bit until it becomes greater than (or less than) the number
> in question.
> 
> M
> --
> Mark Murray
> Join the anti-SPAM movement: http://www.cauce.org
> 
> 

-- 
e-Mail: hi...@skylink.it



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



select/poll implementation

1999-08-22 Thread Jay Nordwick
I had always wondered how select/poll worked (actually see the end of the
mail to see the broader question), so I pulled up select() and family
and started reading and chasing stuff around.  I think that I fully
understand (much praise to whoever wrote most of that, it was incredibly
easy to read) everything from sys_generic.c.

I just need someone to clear up a couple things:

1) It seems that all select (and poll) calls wait on the same
   condition variable (selwait), so when you wake up on select/poll
call, you wake them all up.  (selwakeup() seems to call wake()
on selwait, but then hunts for a specific process to make runnable(),
I'm confused).

2) Where does the struct sockbuf -> struct selinfo sb_sel get filled
   in?  I see it passed around, but I do not see select setting it
before it tsleeps() on selwait.


thanks
-jason

P.S., Specifically, I was porting a threaed win32 program to UNIX and pthreads.
The one big problem is that there is some win32 event handling code that
waits for events (a glorified condition variable).  There two procedures
that I have to implement are called WaitForSingleEvent() and
WaitForMultipleEvents().  Okay, waiting for a single event is easy to
implement, but waiting for any of multiple events seems more difficult.
I thought to go see how select()/poll() did it, since it did something
similar.




To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Daniel C. Sobral
John-Mark Gurney wrote:
> 
> > Shift a bit until it becomes greater than (or less than) the number
> > in question.
> 
> ummm, didn't you read his post?? he wanted a O(1) routine, NOT a O(n)
> routine...

That technique is O(ln(n)), where n is the number in question.

Frankly, for numbers up to 32, a table will wield the best results,
and might actually be smaller than some of the suggestions given so
far.

--
Daniel C. Sobral(8-DCS)
d...@newsguy.com
d...@freebsd.org

- Come on.
- Where are we going?
- To get what you came for.
- What's that?
- Me.


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: IDE quirk in 3.2-STABLE kernel ?

1999-08-22 Thread Daniel C. Sobral
Chris wrote:
> 
> I am glad to hear from Soren that this 'misconfiguration' will be
> supported in 4.0
> As always when a misconfiguration (read 'not to spec') is used enough
> then it quickly becomes somewhat of a de facto standard.

Old message, but still in need for reply.

Yeah, like isa shared irq's which are no longer supported by
Windows, or pcmcia card removal without previous deactivation which
is no longer supported by Windows, but were all "de facto"
standards.

What happens is that these "de facto" standards usually work only by
accident, only with certain hardware configurations, only with
certain loads, and/or only if the operating system adheres to
certain restrictions (like not being truly multitasking).

FreeBSD's main target is servers. Sure, we do care about desktop,
despite the common claim that we leave that to Linux. But the *main*
target is servers, and if supporting a "de facto standard" will
detract from support for server configurations, we will *not*
support it.

Alas, in most case is just a matter of making options for buggy
hardware/bios/whatever. But, again, people working on FreeBSD is
most likely to devote their time to making *good* hardware work than
making bad hardware work. And the same applies for the case above.

--
Daniel C. Sobral(8-DCS)
d...@newsguy.com
d...@freebsd.org

- Come on.
- Where are we going?
- To get what you came for.
- What's that?
- Me.



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Peter Dufault
> It seems that all the solutions are too generic and slow. As I only have
> to check the numbers 0-32 (actually 1-32), a block of if statements is
> almost as fast as a table look up in 33 elements.

I doubt it - use the table for a small fixed size set then
use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0".
The possible inline ffs is in machine/cpufunc.h

ffs() is fundamental to scheduling queues and cryptography and
should have attention paid to it.  As Warner said, it could be
a single instruction on some architectures.

Peter

-- 
Peter Dufault (dufa...@hda.com)   Realtime development, Machine control,
HD Associates, Inc.   Safety critical systems, Agency approval


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Kazufumi-MIT-Mitani
 "Daniel C. Sobral"  wrote

> That technique is O(ln(n)), where n is the number in question.
> 
> Frankly, for numbers up to 32, a table will wield the best results,
> and might actually be smaller than some of the suggestions given so
> far.

Counting n as bit, it is O(n) :p

Unrolling the loop,

if(n<=2^0) 2^0
else if(n<=2^1) 2^1
else if(n<=2^2) 2^2
else if(n<=2^3) 2^3
   :
   :
else if(n<=2^31) 2^31

is suitable for this problem?

---
//mit



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Nick Hibma

Unfortunately the kernel is compiled with -O which does not include
inlining (dunno about explicit inlining, but don't think so).

Nick

On Sun, 22 Aug 1999, Peter Dufault wrote:

> > It seems that all the solutions are too generic and slow. As I only have
> > to check the numbers 0-32 (actually 1-32), a block of if statements is
> > almost as fast as a table look up in 33 elements.
> 
> I doubt it - use the table for a small fixed size set then
> use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0".
> The possible inline ffs is in machine/cpufunc.h
> 
> ffs() is fundamental to scheduling queues and cryptography and
> should have attention paid to it.  As Warner said, it could be
> a single instruction on some architectures.
> 
> Peter
> 
> -- 
> Peter Dufault (dufa...@hda.com)   Realtime development, Machine control,
> HD Associates, Inc.   Safety critical systems, Agency approval
> 
> 

-- 
e-Mail: hi...@skylink.it



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Tommy Hallgren
--- Kazufumi-MIT-Mitani  skrev:
>  "Daniel C. Sobral"  wrote
> 
> > That technique is O(ln(n)), where n is the number in question.
> > 
> > Frankly, for numbers up to 32, a table will wield the best results,
> > and might actually be smaller than some of the suggestions given so
> > far.
> 
> Counting n as bit, it is O(n) :p

No it isn't. You're only looping a maximum of 32 times, not 2^32 times.

> Unrolling the loop,
> 
> if(n<=2^0) 2^0
> else if(n<=2^1) 2^1
> else if(n<=2^2) 2^2
> else if(n<=2^3) 2^3
>:
>:
> else if(n<=2^31) 2^31
> 
> is suitable for this problem?

IMHO, the best solution so far, if a lookup table isn't suitable, is the binary
search version that someone posted.

Regards, Tommy

===
Tommy Hallgren
Briljantg. 31, SE-421 49, Göteborg
Tel.: 0709 - 312 404 (GSM)
Tel.: 031 - 47 65 28 (Home)
__
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



font edit tools

1999-08-22 Thread Alexey M. Zelkin
hi,

Which tools can be used to edit syscons fonts ?

Any references are welcome!

-- 
Sincerely Yours,   | phan...@crimea.edu  (primary)
Alexey Zelkin  | phan...@scorpion.crimea.ua (home)
   | ICQ: #6196584,  FIDO: 2:460/12.26


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: font edit tools

1999-08-22 Thread Sergey Babkin
Alexey M. Zelkin wrote:
> 
> hi,
> 
> Which tools can be used to edit syscons fonts ?

Any of the tools you use to edit the DOS fonts.
My favorite one it Evafont by Pete Kvitek. But
there were a lot of tools floating around.

-SB


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Async NFS exports?

1999-08-22 Thread Doug Rabson
On Fri, 20 Aug 1999, Matthew Dillon wrote:

> :> Just to be clear... I am wondering if mounting (on the NFS _server_) a
> :> partition (that is exportable) as async will have any performance 
> :> benefits to the NFS clients?
> :
> :As a first guess, probably not unless you have a large number of active
> :clients.  Any modern hard disc will outperform ethernet/fast ethernet,
> :especially for larger read/writes.  For large numbers of smaller
> :operations, or when there is a large number of simultaneous outstanding
> :requests from clients, maybe.  I'd say watch the disc itself (iostat is
> :your friend), and if it's pegged (especially large numbers of tps) async
> :might buy you some increase.
> :-- 
> :Matthew Fuller (MF4839) |fulle...@over-yonder.net
> 
> Not much if at all, whether you have a large number of clients or not,
> at least if you are using NFSv3 mounts.
> 
> The reason is due to the way NFSv3 issues writes.  NFSv3 issues a 
> write but no longer assumes that the write has been synced to the 
> server's disk as of when the reply comes back.  Instead it keeps the
> buffer around and does a later commit rpc to do the sync, presumably
> long after the server has already synced the data. 
> 
> So, effectively, all NFSv3 writes are async insofar as the client's 
> buffer cache is able to keep abrest of the write-rate.
> 
> Hmm, interesting.  I see another optimization I can do to fix the
> buffer cache saturation case in CURRENT on the client.  The COMMIT rpc's
> aren't being issued async.

You need to track the return value of the commit so that you can detect
server reboots and sync-write the data again. If you change to async, make
sure that you still keep this part - its essential to the protocol.

--
Doug Rabson Mail:  d...@nlsystems.com
Nonlinear Systems Ltd.  Phone: +44 181 442 9037




To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Async NFS exports?

1999-08-22 Thread Matthew Dillon
:> buffer cache is able to keep abrest of the write-rate.
:> 
:> Hmm, interesting.  I see another optimization I can do to fix the
:> buffer cache saturation case in CURRENT on the client.  The COMMIT rpc's
:> aren't being issued async.
:
:You need to track the return value of the commit so that you can detect
:server reboots and sync-write the data again. If you change to async, make
:sure that you still keep this part - its essential to the protocol.
:
:--
:Doug RabsonMail:  d...@nlsystems.com
:Nonlinear Systems Ltd. Phone: +44 181 442 9037

   These are buffer-cache entities we are talking about here, so they won't 
   go away until NFS tells the system they can go away.  In that respect
   async I/O is no different then sync I/O.  async I/O is simply run
   synchronously from an nfsiod context.

-Matt
Matthew Dillon 



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Parallel Video Interfaces

1999-08-22 Thread The Evil Anti-Rick
Is anyone doing any work to support parallel video interfaces like
the Snappy or Gotcha cards? I have Snappy card, and I would like to put
it to use as part of an internal video security system.

--R. Pelletier,
Sys Admin, House Galiagante


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: I2C/SMBus/LPBB

1999-08-22 Thread Nicolas Souchu
On Sat, Aug 21, 1999 at 02:46:51AM -0400, Mike Nowlin wrote:
>
>
>I had sent this message to -stable about a month ago, never heard anything
>-- so am trying it here. 

Hmm lpbb seem to fail completly then...

I have to give it a try. Ask me again if I fail to remember. I'm a bit busy.

Thanks for your attempts.

Nicholas

-- 
nso...@teaser.fr / nso...@freebsd.org
FreeBSD - Turning PCs into workstations - http://www.FreeBSD.org


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: font edit tools

1999-08-22 Thread Ollivier Robert
According to Sergey Babkin:
> Any of the tools you use to edit the DOS fonts.
> My favorite one it Evafont by Pete Kvitek. But
> there were a lot of tools floating around.

I know do the opposite. I modify the font with XmBDFED in BDF format then
generate the syscons font with a small Perl script. A logn time ago I used
Evafont too. Nice program.
-- 
Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- robe...@keltia.freenix.fr
FreeBSD keltia.freenix.fr 4.0-CURRENT #73: Sat Jul 31 15:36:05 CEST 1999



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Peter Wemm
Peter Dufault wrote:
> > It seems that all the solutions are too generic and slow. As I only have
> > to check the numbers 0-32 (actually 1-32), a block of if statements is
> > almost as fast as a table look up in 33 elements.
> 
> I doubt it - use the table for a small fixed size set then
> use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0".
> The possible inline ffs is in machine/cpufunc.h
> 
> ffs() is fundamental to scheduling queues and cryptography and
> should have attention paid to it.  As Warner said, it could be
> a single instruction on some architectures.

ffs() works from the wrong direction though.  He needs the MSB, not the LSB.

There is a fls() inline in  though, at least for the x86
family which I think will return the bit number (range: 32 - 1) of the MSB.

So, to get the rounded down (and up) power-of-two value you'd do:

#include 
#include 
#include 

main()
{
int i, down, up;

for (i = 0; i < 65; i++) {
down = i ? (1 << (fls(i) - 1)) : 0;
up = 1 << fls(i);
printf("%d %d %d\n", i, down, up);
}
}

I'm not sure what you want at zero, but the result is:
0  0  1
1  1  2
2  2  4
3  2  4
4  4  8
5  4  8
6  4  8
7  4  8
8  8 16
9  8 16
10 8 16
11 8 16
12 8 16
13 8 16
14 8 16
15 8 16
16 16 32
17 16 32

The << is normally implemented as a barrel shift on most modern CPU's.

The other key trick is (x) & -(x).  That returns the LSB in position, not
the bit number.

ie: 12 & -12 =
  1100
& 0100 (twos complement, in byte form)
= 0100 = 4 = the value of the LSB.

Cheers,
-Peter
--
Peter Wemm - pe...@freebsd.org; pe...@yahoo-inc.com; pe...@netplex.com.au



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: font edit tools

1999-08-22 Thread Dan Nelson
In the last episode (Aug 22), Sergey Babkin said:
> Alexey M. Zelkin wrote:
> > 
> > hi,
> > 
> > Which tools can be used to edit syscons fonts ?
> 
> Any of the tools you use to edit the DOS fonts.
> My favorite one it Evafont by Pete Kvitek. But
> there were a lot of tools floating around.

I like one called Font Mania!; the author doesn't seem to have a web
presence, but an URL is http://jconroy.dragonfire.net/zzt/utilities/Fm.zip

-- 
Dan Nelson
dnel...@emsphone.com


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: select/poll implementation

1999-08-22 Thread Nate Williams
> I had always wondered how select/poll worked (actually see the end of the
> mail to see the broader question), so I pulled up select() and family
> and started reading and chasing stuff around.  I think that I fully
> understand (much praise to whoever wrote most of that, it was incredibly
> easy to read) everything from sys_generic.c.

Sean Fagan walked me through the code a couple of years ago, and after
our discussion he decided to submit this to Dr. Dobbs.  The article
should be available in their archives somewhere to explain these things
in some detail, and should answer the questions you have.


Nate


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Mandatory locking?

1999-08-22 Thread Greg Lehey
I've just found a need for mandatory locking in Vinum, and I'm
wondering how to implement it.  If I understand things correctly, our
fcntl locking doesn't perform mandatory locking, though System V does
if you set the file permissions appropriately.

Questions:

1.  Do we have some form of mandatory locking?  If so, what is it?

2.  Would it make sense to implement System V's fcntl semantics?
They're rather tacky: you set the setgid bit and reset the group
exec bit of the file permissions.

3.  Alternatively (or additionally), would it make sense to have an
additional fcntl function which performs mandatory locking?

I think that it's probably a good idea to implement (3), and also to
do (2), possibly subject to a sysctl knob.

Greg
--
See complete headers for address, home page and phone numbers
finger g...@lemis.com for PGP public key


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Brian F. Feldman
On Sun, 22 Aug 1999, Nick Hibma wrote:

> 
> Unfortunately the kernel is compiled with -O which does not include
> inlining (dunno about explicit inlining, but don't think so).
> 
> Nick

-O lets you do explicit inlining, and -O2 enables -finline-functions.
Anyway, I think the simple solution to the problem for this case
is a switch, since GCC creates optimizations nicely with those :)

-- 
 Brian Fundakowski Feldman   /  "Any sufficiently advanced bug is\
 gr...@freebsd.org   |   indistinguishable from a feature."  |
 FreeBSD: The Power to Serve!\-- Rich Kulawiec   /



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Matthew Dillon

:Questions:
:
:1.  Do we have some form of mandatory locking?  If so, what is it?

No we don't, unless you count the ad-hoc lockout in the master/slave pty 
interface :-).

:2.  Would it make sense to implement System V's fcntl semantics?
:They're rather tacky: you set the setgid bit and reset the group
:exec bit of the file permissions.

Ugh.  Yuch.  No, nothing to do with permission bits, not for something
this convoluted!

:3.  Alternatively (or additionally), would it make sense to have an
:additional fcntl function which performs mandatory locking?
:
:I think that it's probably a good idea to implement (3), and also to
:do (2), possibly subject to a sysctl knob.
:
:Greg

Well, #3 can't be mandatory if you have to make a fcntl call!  You mean
have one program make a fcntl call that causes other programs to
return an error or block if they try to open that file while the first
program holds an open descriptor?

-Matt
Matthew Dillon 



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey
On Sunday, 22 August 1999 at 17:31:44 -0700, Matthew Dillon wrote:
>
>> Questions:
>> 
>> 1.  Do we have some form of mandatory locking?  If so, what is it?
>
> No we don't, unless you count the ad-hoc lockout in the master/slave pty
> interface :-).
>
>> 2.  Would it make sense to implement System V's fcntl semantics?
>> They're rather tacky: you set the setgid bit and reset the group
>> exec bit of the file permissions.
>
> Ugh.  Yuch.  No, nothing to do with permission bits, not for something
> this convoluted!

I don't like it either, but for compatibility reasons it would make
sense.  That's why I suggested a sysctl knob.

>> 3.  Alternatively (or additionally), would it make sense to have an
>> additional fcntl function which performs mandatory locking?
>> 
>> I think that it's probably a good idea to implement (3), and also to
>> do (2), possibly subject to a sysctl knob.
>
> Well, #3 can't be mandatory if you have to make a fcntl call!

Somehow you need to get a lock.

> You mean have one program make a fcntl call that causes other
> programs to return an error or block if they try to open that
> file while the first program holds an open descriptor?

Correct.  I suppose it's worth discussing what the default should be.
Should they get EAGAIN or block?  Obviously you'd want a way of
specifying which, but there would have to be a default for
non-lock-aware programs.  I think I'd go for blocking; it's less error
prone.

Greg
--
See complete headers for address, home page and phone numbers
finger g...@lemis.com for PGP public key


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



What does unp stand for?

1999-08-22 Thread Zhihui Zhang

In file uipc_usrreq.c, there are many routines beginning with unp_. For
example, unp_connect(), unp_bind(), etc. What does unp stand for?  

Thanks. 

--
Zhihui Zhang.  Please visit http://www.freebsd.org
--



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: What does unp stand for?

1999-08-22 Thread Bill Fumerola
On Sun, 22 Aug 1999, Zhihui Zhang wrote:

> In file uipc_usrreq.c, there are many routines beginning with unp_. For
> example, unp_connect(), unp_bind(), etc. What does unp stand for?  


W. Richard Stevens wrote a book Unix Network Programming often refered
to by UNP, which includes his improved versions of socket functions.


The above could be completly wrong.

-- 
- bill fumerola - bi...@chc-chimes.com - BF1560 - computer horizons corp -
- ph:(800) 252-2421 - bfume...@computerhorizons.com - bi...@freebsd.org  -






To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: mmap mapped segment length

1999-08-22 Thread Wes Peters
Matthew Dillon wrote:
> 
> :Now I've got to go figure out what *I've* screwed up.  I fstat the file 
> before
> :mapping it and pass S.st_size as the map length.  Is there any reason why
> :mmap would return non-NULL but map less than the requested size?
> :
> :Scratching my head,
> 
> Note that mmap() returns (void *)-1 when an error occurs, *not* NULL.
> 
> This is because it is legal to mmap at address 0.

Uh, yeah, the program source actually checks against MAP_FAILED.  I do usually
read the man pages when I write code.  ;^)

I found the problem, it was caused by unexpected input.  Doh!  The program is
now working, and is on the 44th (of 78) 60 megabyte input files.  Good thing
the REAL system is a dual PII Xeon 450, huh?  Maybe I should add a -j jobs 
option so I can make sure we use that other processor.  As I/O bound as 
this task is, I'm not sure it would help.

Thanks to everyone who responded, and for the politeness of the responses in
the face of the stupidity of the original question.

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

Wes Peters Softweyr LLC
http://softweyr.com/   w...@softweyr.com


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: What does unp stand for?

1999-08-22 Thread Brian F. Feldman
On Sun, 22 Aug 1999, Bill Fumerola wrote:

> On Sun, 22 Aug 1999, Zhihui Zhang wrote:
> 
> > In file uipc_usrreq.c, there are many routines beginning with unp_. For
> > example, unp_connect(), unp_bind(), etc. What does unp stand for?  
> 
> 
> W. Richard Stevens wrote a book Unix Network Programming often refered
> to by UNP, which includes his improved versions of socket functions.
> 
> 
> The above could be completly wrong.

Actually, I'm pretty sure it standard for Unix network protocol, as in
good old PF_UNIX/PF_LOCAL.

-- 
 Brian Fundakowski Feldman   /  "Any sufficiently advanced bug is\
 gr...@freebsd.org   |   indistinguishable from a feature."  |
 FreeBSD: The Power to Serve!\-- Rich Kulawiec   /



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Bakul Shah
The best I can come up with is this:

/*  kk+1 k
 * given n, return 2  such that 2> n >= 2
 */
inline unsigned long
n2power2(unsigned long n)
{
/* `smear' the highest set bit to the right */
n |= n>>1; n |= n>>2; n |= n>>4; n |= n>>8; n |= n>>16;
/* now n is of the form 0..01..1 */
return n & ~(n>>1);
}

Note that n bit shift is also O(n) on many machines but
usually a machine instruction implements it so this may still
be faster than 5 or 6 compares and branches that you would
need if a binary search was used.  But
n ? 1 << (fls(n)-1) : 0
where fls is inlined may still beat it!

-- bakul


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Garrett Wollman
< said:

> Correct.  I suppose it's worth discussing what the default should be.
> Should they get EAGAIN or block?  Obviously you'd want a way of
> specifying which, but there would have to be a default for
> non-lock-aware programs.  I think I'd go for blocking; it's less error
> prone.

I'd be strongly opposed to any sort of mandatory locking.  The whole
notion is unspeakably evil, although this is mitigated somewhat if it
does not apply to processes with appropriate privilege.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
woll...@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey
On Sunday, 22 August 1999 at 22:07:04 -0400, Garrett Wollman wrote:
> < said:
>
>> Correct.  I suppose it's worth discussing what the default should be.
>> Should they get EAGAIN or block?  Obviously you'd want a way of
>> specifying which, but there would have to be a default for
>> non-lock-aware programs.  I think I'd go for blocking; it's less error
>> prone.
>
> I'd be strongly opposed to any sort of mandatory locking.  The whole
> notion is unspeakably evil, although this is mitigated somewhat if it
> does not apply to processes with appropriate privilege.

That's a strange thing to say.  Should we do away with locks in the
kernel too?

Greg
--
See complete headers for address, home page and phone numbers
finger g...@lemis.com for PGP public key


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Matthew Dillon

:Somehow you need to get a lock.
:
:> You mean have one program make a fcntl call that causes other
:> programs to return an error or block if they try to open that
:> file while the first program holds an open descriptor?
:
:Correct.  I suppose it's worth discussing what the default should be.
:Should they get EAGAIN or block?  Obviously you'd want a way of
:specifying which, but there would have to be a default for
:non-lock-aware programs.  I think I'd go for blocking; it's less error
:prone.
:
:Greg

I dunno, it sounds pretty icky to me.   I would redesign whatever you
are doing that requires mandatory locks to use advisory locks instead.
It can be as simple as a wrapper around whatever program your users are
running that is causing whatever the problem is.

-Matt
Matthew Dillon 



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Interesting ssh + X + tcp_wrappers problem

1999-08-22 Thread Doug
I've been doing some housecleaning lately and I finally decided to set 
up
a one-way ssh authentication from my workstation to my gateway machine. I
set up the ssh keys and that was all good. Then I went to start an X app on
the gateway expecting it to just pop up on the workstation's X display
(happens to be cvsup, but I don't think that's relevant) and I got the
following:

error: Fwd X11 connection from dt010nb9.san.rr.com refused by tcp_wrappers.

I am using natd on the gateway to hook me up to my cable modem. The
hostname is the one that the world sees me as, and is assigned to the
outside interface. I have the inside interface set up as 10.0.0.1, and the
workstation is 10.0.0.2. I have ALL : 10.0.0.2 : allow in /etc/hosts.allow
(and appropriate ipfw filtering set up of course), but I didn't have the
address of the outside interface in there anywhere since I never expected
it would be a problem for the machine to connect to itself. :) 

Now I am not sure if this is an sshd problem, an X problem, a 
tcp_wrappers
problem, or what have you. I do know that once I put an entry for the
outside interface address in hosts.allow it worked. The only problem I have
with that is that with dhcp that address changes every time someone gets a
wild hair and reboots the dhcp server, and they do that a couple times a
month. This makes one more thing that I have to add to my
"bugger-I-got-another-new-IP" script that I'd prefer to avoid. 

Thoughts, comments, suggestions welcome,

Doug


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Greg Lehey
On Sunday, 22 August 1999 at 22:04:38 -0700, Matthew Dillon wrote:
>
>> Somehow you need to get a lock.
>>
>>> You mean have one program make a fcntl call that causes other
>>> programs to return an error or block if they try to open that
>>> file while the first program holds an open descriptor?
>>
>> Correct.  I suppose it's worth discussing what the default should be.
>> Should they get EAGAIN or block?  Obviously you'd want a way of
>> specifying which, but there would have to be a default for
>> non-lock-aware programs.  I think I'd go for blocking; it's less error
>> prone.
>
> I dunno, it sounds pretty icky to me.   I would redesign whatever you
> are doing that requires mandatory locks to use advisory locks
> instead.
>
> It can be as simple as a wrapper around whatever program your users are
> running that is causing whatever the problem is.

I'm accessing a file that any program might want to open.  Redesigning
everything isn't an option.

On Monday, 23 August 1999 at  7:29:32 +0200, Poul-Henning Kamp wrote:
> In message <19990823122719.g83...@freebie.lemis.com>, Greg Lehey writes:
>> On Sunday, 22 August 1999 at 22:52:33 -0400, Garrett Wollman wrote:
>>> < said:
>>>
 That's a strange thing to say.  Should we do away with locks in the
 kernel too?
>>>
>>> Of course not.  Locks in the kernel are actually necessary.
>>
>> So what's unspeakably evil about ensuring that user processes don't
>> tread on each other's feet?  In my specific case, I need to make a
>> Vinum volume inaccessible while rebuilding the parity stripes.  How
>> would you ensure that?  A user process is doing the rebuilding.
>
> Then you give that user-process a magic ioctl to do it with.

That sounds like a kludge to me.

> Why should it be made unavailable ?

So that certain multiple accesses can be done atomically.

> I thought the idea of RAID-5 was that this wasn't needed ?

No, the idea of RAID-5 is that you can tolerate failures.

I'm a little surprised that there's any objection to the concept of
mandatory locking.  In transaction processing, locking is not
optional, and if any process at all can access a file or set of files
without locking, you can't guarantee the database integrity.  Other
OSs have used mandatory locking for decades, and System V has it too.
So far I haven't seen any arguments, let alone valid ones, against
having it in FreeBSD.

Greg
--
See complete headers for address, home page and phone numbers
finger g...@lemis.com for PGP public key


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: from number to power of two

1999-08-22 Thread Ollivier Robert
According to Brian F. Feldman:
> -O lets you do explicit inlining, and -O2 enables -finline-functions.

You meant -O3 of course.

   -O3Optimize yet more. This  turns  on  everything  -O2
  does,  along  with  also  turning on -finline-func-
  tions.
-- 
Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- robe...@keltia.freenix.fr
FreeBSD keltia.freenix.fr 4.0-CURRENT #73: Sat Jul 31 15:36:05 CEST 1999



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message



Re: Mandatory locking?

1999-08-22 Thread Daniel O'Connor

On 23-Aug-99 Greg Lehey wrote:
>  I'm a little surprised that there's any objection to the concept of
>  mandatory locking.  In transaction processing, locking is not
>  optional, and if any process at all can access a file or set of files
>  without locking, you can't guarantee the database integrity.  Other
>  OSs have used mandatory locking for decades, and System V has it too.
>  So far I haven't seen any arguments, let alone valid ones, against
>  having it in FreeBSD.

I think its a good idea, and hey if people object it can always be an option
like ->

option NO_MANDATORY_LOCKING

Phew, that was tough.

---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum


pgpUZ9kdbjmC7.pgp
Description: PGP signature


Re: Mandatory locking?

1999-08-22 Thread Poul-Henning Kamp
In message <19990823152849.h83...@freebie.lemis.com>, Greg Lehey writes:

>> Why should it be made unavailable ?
>
>So that certain multiple accesses can be done atomically.

You don't need that.  You initialize a index to 0, and whenever
the sector with that index is written, you increment it.

At any one time you know that all parityblocks <= your index
are valid.

All you need to do to recover you index then is to have an
ioctl which will read one sector at a time, mark the buffer
dirty write it out again.

I have seen sources for two well-respected RAID-5 products
which do it this way.

>I'm a little surprised that there's any objection to the concept of
>mandatory locking.

Too many of us have had wedged systems because of it I guess...

--
Poul-Henning Kamp FreeBSD coreteam member
p...@freebsd.org   "Real hackers run -current on their laptop."
FreeBSD -- It will take a long time before progress goes too far!


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message