Re: PThreads and Sockets

1999-11-27 Thread FengYue


On Sat, 27 Nov 1999, Rob King wrote:

> 
> How would you recommend I do it? Please remember, I have no experience
> with pthreads, and any advice you give would be greatly appreciated.

There are couple of ways you could do this:

1) pass sd2's value instead of its memory address to serverstart()
pthread_create(&thread1, pthread_attr_default,serverstart, sd2);
   then inside serverstart:
void serverstart (void *p)
{
int sockfd = (int) p;
blah...blah
}

if you worry about void * being not as the same size as int on
some platforms, then u should use 2)

2) Use a mutex lock:
pthread_mutex_lock (&mp_lock);
_do_the_accept_
_create_thread_
inside serverstart(), right after u def' the pointer, do this
pthread_mutex_unlock (&mp_lock);

> 
> I tried doing a pool of threads created at startup, and I think that may
> be a better approach...That would allow tighter control of resource limits
> - do something like Apache, have a "maximum number" of processes running.

Yes, that's a better approach in many cases.  Creating threads itself
is a quiet expensive operation.



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



Re: mbuf wait code (revisited) -- review?

1999-11-27 Thread Matthew Dillon

:of other connections. My solution was the same as Matt's :-)
:(I'm not happy about the extra context switching that it requires but
:I was more interested in working code than performance; I haven't
:benchmarked it.)
:
:Tony.

Yah, neither was I, but I figured that the overhead was (A) deterministic,
and (B) absorbed under heavy loads because the subprocess in question was
probably already in a run state under those conditions.  So the method
scales to load quite well and gives us loads of other features.  For 
example, I could do realtime reverse DNS lookups with a single cache 
(in the main acceptor process) and then a pool of DNS lookup subprocesses
which I communicated with over pipes.  Thus the main load-bearing threads
had very small core loops which was good for the L1/L2 cpu caches.

It's kinda funny how something you might expect to generate more overhead
can actually generate less.

-Matt




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



Re: PThreads and Sockets

1999-11-27 Thread Dan Moschuk


| > Try this.
| > 
| > void *serverstart(void *ptr)
| > {
| > int sd2;
| > 
| > sd2 = *((int *) ptr);
| > ...
| > }
| 
| There is a race condition.  You're passing sd2's address to serverstart()
| and inside serverstart() you def' the pointer.  What if
| "sd2=accept(sd, (struct sockaddr*)&cad, &alen)" gets
| executed before your previous serverstart() finishs "sd2 = *((int*)ptr)"?

Since accept isn't atomic, it would be best to enclose the whole sha-bang in
a mutex up until the sd2 = *((int *) ptr) call finishes.
--
Dan Moschuk ([EMAIL PROTECTED])
"Try not.  Do, or do not.  There is no try."
-- Yoda


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



Test code...

1999-11-27 Thread Brian J. McGovern

Anyone have any suggestions (or feel like writing) code to exercise the
following subsystems?

- Virtual Memory

- The threads library

- mmap() and friends

We want to try to bang on them a little more for 3.4 than we have in the past.
-Brian


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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Vladimir N. Silyaev

Hi
> Secondly; you don't install the vmware-wizard script.  Are there others
> that you might have missed?
What is the sense to install this script, when it doesn't have any
chance to working??? It really very dependent from linux internals.
At this time only one application working the vmware, nor vmware-wizard,
nor something else.

Ok. New port, based on the VMware 1.1.2 will be install all the executables.

This port available right now from the old url:
http://www.mindspring.com/~vsilyaev/vmware/vmware.tar.gz

Nothing changed, only version number and user level application.

Vladimir Silyaev.



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



Re: PThreads and Sockets

1999-11-27 Thread Rob King

> There is a race condition.  You're passing sd2's address to serverstart()
> and inside serverstart() you def' the pointer.  What if
> "sd2=accept(sd, (struct sockaddr*)&cad, &alen)" gets
> executed before your previous serverstart() finishs "sd2 = *((int*)ptr)"?
> 
> btw, IMHO, creating threads per connection is a very bad design.
> 
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 

How would you recommend I do it? Please remember, I have no experience
with pthreads, and any advice you give would be greatly appreciated.

I tried doing a pool of threads created at startup, and I think that may
be a better approach...That would allow tighter control of resource limits
- do something like Apache, have a "maximum number" of processes running.

Anyway, thanks for the help.

Rob

-- 

Rob King
Network Administrator - PERnet Communications, Inc.
[EMAIL PROTECTED]  - http://www.pernet.net/



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



Re: PThreads and Sockets

1999-11-27 Thread FengYue


On Fri, 26 Nov 1999, Dan Moschuk wrote:

> 
> | int sd2;
> | if((sd2=accept(sd, (struct sockaddr*)&cad, &alen)) > 0) {
> | pthread_create(&thread1, pthread_attr_default,
> |serverstart, &sd2);
> | }
> | 
> | Then the serverstart function:
> | 
> | void *serverstart(void *ptr)
> | {
> | int *sd2;
> | sd2 = (int*)ptr;
> | 
> | dowhatever(sd2);
> | }
> |
> | Any ideas as to what I'm doing wrong? Also, thanks for your help.
> | 
> | Rob
> 
> Try this.
> 
> void *serverstart(void *ptr)
> {
>   int sd2;
> 
>   sd2 = *((int *) ptr);
>   ...
> }

There is a race condition.  You're passing sd2's address to serverstart()
and inside serverstart() you def' the pointer.  What if
"sd2=accept(sd, (struct sockaddr*)&cad, &alen)" gets
executed before your previous serverstart() finishs "sd2 = *((int*)ptr)"?

btw, IMHO, creating threads per connection is a very bad design.



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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Mike Smith

> At this time I can successful run the VMware 1.1 for Linux on the FreeBSD.

Ok.  Now I have some real commentary, and sorry for the erroneous 
complaint before.

Firstly; the detection you do for a patched Linux module is great.  I was 
very happy to be told off for not loading a new one first. 8)

Secondly; you don't install the vmware-wizard script.  Are there others 
that you might have missed?
-- 
\\ Give a man a fish, and you feed him for a day. \\  Mike Smith
\\ Tell him he should learn how to fish himself,  \\  [EMAIL PROTECTED]
\\ and he'll hate you for a lifetime. \\  [EMAIL PROTECTED]




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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Vladimir N. Silyaev

Hi

> >This is great stuff, unfortunately VMware 1.1.1-330 isn't available 
> >anymore.  Any chance of you updating your port to work with 1.1.2-364?
> >
> 
> I just grabbed VMware-1.1.1-330.tar.gz using his port, no problem.
> 
> Couldn't run vmware, it complains that it can't find /dev/tty0 and
> exits.

Did you read section about Full Screen mode from README.FreeBSD file:

   - Fullscreen modes
VMware would not even started session when our DISPLAY
variable will be like ':0.0'. So to run VMware on the local
display you are need to change DISPLAY environment to something
like 'localhost:0.0'. For example use the following commands
(for bourne shell):
DISPLAY=localhost${DISPLAY};export DISPLAY

Vladimir Silyaev



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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Mike Smith

> 
> This is great stuff, unfortunately VMware 1.1.1-330 isn't available 
> anymore.  Any chance of you updating your port to work with 1.1.2-364?

I take that back; it is available, but the 1.1.2 version is current.

Now to see if I can wrangle this into working...

-- 
\\ Give a man a fish, and you feed him for a day. \\  Mike Smith
\\ Tell him he should learn how to fish himself,  \\  [EMAIL PROTECTED]
\\ and he'll hate you for a lifetime. \\  [EMAIL PROTECTED]




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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Vladimir N. Silyaev

Hi

> This is great stuff, unfortunately VMware 1.1.1-330 isn't available 
> anymore.  
I'm sorry what is mean not available? At this time you can download it
from the VMware download sites (but you are need to know right URL,
and port really know it).

When you are obatined license, only mean major version number. 
>From VMware website:
Product [VMware 1.1.x for Linux] 

> Any chance of you updating your port to work with 1.1.2-364?
Sure. But right now, I don't investegate the difference between these
versions. 

And I think will be very helpful to do some testing of the existing
versions, because this driver doing some very unclean things with
virtual memory.

Vladimir N. Silyaev



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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Gary Jennejohn

Mike Smith writes:
>
>This is great stuff, unfortunately VMware 1.1.1-330 isn't available 
>anymore.  Any chance of you updating your port to work with 1.1.2-364?
>

I just grabbed VMware-1.1.1-330.tar.gz using his port, no problem.

Couldn't run vmware, it complains that it can't find /dev/tty0 and
exits.

>> At this time I can successful run the VMware 1.1 for Linux on the FreeBSD.
>> It could be used to run Linux on the FreeBSD box, or to run another FreeBSD
>> on the same box. Of course you can run some piece of Microsoft products:
>> MS DOS, Windows 9X, Windows NT and etc. You can download the port 
>> (NOTE: -current only) from:
>> 
>>  http://www.mindspring.com/~vsilyaev/vmware/vmware.tar.gz
>> 
>> 
>> Some more information about this port available at:
>>  http://www.mindspring.com/~vsilyaev/vmware/
>> 
>> General information about VMware available at:
>>  http://www.vmware.com
>> 
>> 
>> Vladimir N. Silyaev
>> 
>> 
>> 
>> To Unsubscribe: send mail to [EMAIL PROTECTED]
>> with "unsubscribe freebsd-hackers" in the body of the message
>> 
>
>-- 
>\\ Give a man a fish, and you feed him for a day. \\  Mike Smith
>\\ Tell him he should learn how to fish himself,  \\  [EMAIL PROTECTED]
>\\ and he'll hate you for a lifetime. \\  [EMAIL PROTECTED]
>
>
>
>
>To Unsubscribe: send mail to [EMAIL PROTECTED]
>with "unsubscribe freebsd-emulation" in the body of the message
>

---
Gary Jennejohn / [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]




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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Mike Smith


This is great stuff, unfortunately VMware 1.1.1-330 isn't available 
anymore.  Any chance of you updating your port to work with 1.1.2-364?

> At this time I can successful run the VMware 1.1 for Linux on the FreeBSD.
> It could be used to run Linux on the FreeBSD box, or to run another FreeBSD
> on the same box. Of course you can run some piece of Microsoft products:
> MS DOS, Windows 9X, Windows NT and etc. You can download the port 
> (NOTE: -current only) from:
> 
>   http://www.mindspring.com/~vsilyaev/vmware/vmware.tar.gz
> 
> 
> Some more information about this port available at:
>   http://www.mindspring.com/~vsilyaev/vmware/
> 
> General information about VMware available at:
>   http://www.vmware.com
> 
> 
> Vladimir N. Silyaev
> 
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 

-- 
\\ Give a man a fish, and you feed him for a day. \\  Mike Smith
\\ Tell him he should learn how to fish himself,  \\  [EMAIL PROTECTED]
\\ and he'll hate you for a lifetime. \\  [EMAIL PROTECTED]




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



Re: ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Doug Rabson

On Sat, 27 Nov 1999, Vladimir N. Silyaev wrote:

> Hi,
> 
> At this time I can successful run the VMware 1.1 for Linux on the FreeBSD.
> It could be used to run Linux on the FreeBSD box, or to run another FreeBSD
> on the same box. Of course you can run some piece of Microsoft products:
> MS DOS, Windows 9X, Windows NT and etc. You can download the port 
> (NOTE: -current only) from:
> 
>   http://www.mindspring.com/~vsilyaev/vmware/vmware.tar.gz
> 
> 
> Some more information about this port available at:
>   http://www.mindspring.com/~vsilyaev/vmware/
> 
> General information about VMware available at:
>   http://www.vmware.com
> 
> 
> Vladimir N. Silyaev

Well done indeed! This is excellent work!

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



ANNOUNCE: VMware 1.1 for Linux on the FreeBSD

1999-11-27 Thread Vladimir N. Silyaev

Hi,

At this time I can successful run the VMware 1.1 for Linux on the FreeBSD.
It could be used to run Linux on the FreeBSD box, or to run another FreeBSD
on the same box. Of course you can run some piece of Microsoft products:
MS DOS, Windows 9X, Windows NT and etc. You can download the port 
(NOTE: -current only) from:

http://www.mindspring.com/~vsilyaev/vmware/vmware.tar.gz


Some more information about this port available at:
http://www.mindspring.com/~vsilyaev/vmware/

General information about VMware available at:
http://www.vmware.com


Vladimir N. Silyaev



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