Help with understanding process state, context switching and signals

2003-02-06 Thread Andrey Simonenko
Hello.

After spending some time in reading different mailing lists archives,
analyzing FreeBSD 4.x sys/kern and sys/i386 sources and reading 4.4BSD book
I still can't find an answer, so, I ask my question here.

In short: I need to stop (suspend) some process from the kernel, when
that process is in user mode and get information about its general-purpose
registers, its VM structures, etc.  The quick answer is following: Send
SIGSTOP to that process and do what you want, but this doesn't help me.

I wrote a module for some pseudo device, which allows me to enter to
the system via ioctl() syscall.  Next, I need to determine when target
process *p is in user mode, I suppose that following code is correct:

s = splhigh();
if (p-p_stat == SRUN)
in_user_mode = 1;
splx(s);

because only one process can enter the kernel at a time.
Am I correct here?

Next, when I determine that target process is in user mode I have to
stop (or suspend) it.  As I understand I can't simply remove a process
from the run queue, because the kernel should save the current execution
state of a process in process's PCB.  I suppose that it is possible to
simply remove a process from the run queue if there is only one CPU,
because 4.4BSD kernel is never preempted to run another process, while
executing in a system call (until current executing process force voluntary
context switching).  But such approach does not work on the system with
several CPU.

Am I right about system with one CPU and about system with several CPU?

First my idea was to call psignal(p, SIGSTOP).  But a signal will be
delivered to a target process asynchronously with respect to the current
process.  That is, following code _is not_ correct:

psignal(p, SIGSTOP);
/* From this line process *p is stopped. Is it correct? */

So, I need to stay in loop and checking p-p_stat == SSTOP.  But this is
not correct because current process will get all CPU time.  If current
process relinquishes the processor, then target process will have a chance
to get a signal (in case with the system with one CPU at least).  If current
executing process relinquishes the CPU, then target process has a chance to
enter the kernel.  The kernel checks if there are any pending signals each
time when a process enters the system (in syscall), and if there is SIGSTOP,
then a process will be stopped immediately.  That is I need another
loop which will test if stopped target process was stopped in user mode
(probably compare last Assembler instruction of a process with int 0x80
instruction).

Where am I wrong in my reasoning?

Is there another (or correct) way to suspend some process when it is
in user mode?  The problem actually not in suspending (we have SIGSTOP),
but in synchronization as I understand.

Please help me with understanding all this.

I have another questions, but I think I misunderstood something in
process state, context switching and delivering a signal.

Thanks.


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



Re: New technologies in FreeBSD 5.x vs. 4.x

2003-02-06 Thread Brandon D. Valentine
[ Bcc'd to -current following initial crosspost.  Followups to -hackers
or directly to Mr. Penisoara. ]

On Thu, Feb 06, 2003 at 03:17:15PM +0200, Adrian Penisoara wrote:
 
 Where can I find a (preferrably detailed) list of the new technologies
 introduced with FreeBSD 5.x ?

Greetings Adrian,

The most significant new features are listed in the Release
Announcement[0].  There is greater detail available in the Release Notes
under What's New[1].

 I would also like, if possible, to get in touch with a few of the main
 developers that took charge of coding them.

You can contact the person listed as MAINTAINER in the Makefile for the
part of the source tree you are concerned with.  If there is no
MAINTAINER listed, a quick trip through CVSWeb[2] will reveal who has
been the most active committer to that section of the tree.  I would, of
course, recommend courtesy and patience when approaching FreeBSD
develoeprs for an interview.  Most of them are quite busy.

[0] - http://www.freebsd.org/releases/5.0R/announce.html
[1] - http://www.freebsd.org/releases/5.0R/relnotes-i386.html
[2] - http://www.freebsd.org/cgi/cvsweb.cgi/

Good luck,

Brandon D. Valentine
-- 
[EMAIL PROTECTED] http://www.geekpunk.net

We've been raised on replicas of fake and winding roads, and day after day up
on this beautiful stage we've been playing tambourine for minimum wage, but we
are real; I know we are real.  -- David Berman

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



Re: Help with understanding process state, context switching andsignals

2003-02-06 Thread Dag-Erling Smorgrav
Andrey Simonenko [EMAIL PROTECTED] writes:
 In short: I need to stop (suspend) some process from the kernel, when
 that process is in user mode and get information about its general-purpose
 registers, its VM structures, etc.

Have you looked at ptrace(2)?  That's what gdb(1) uses.  You can get
additional information about memory maps etc. from procfs.

DES
-- 
Dag-Erling Smorgrav - [EMAIL PROTECTED]

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



New technologies in FreeBSD 5.x vs. 4.x

2003-02-06 Thread Adrian Penisoara
Hi,

  I'm about to write an article on FreeBSD for PC Magazine Romania and I
would like to concentrate on the new technologies introduced in FreeBSD
5.x.

  Where can I find a (preferrably detailed) list of the new technologies
introduced with FreeBSD 5.x ? I would also like, if possible, to
get in touch with a few of the main developers that took charge of
coding them.

 Thank you very much,
 Adrian Penisoara
 Ady (@freebsd.ady.ro, @rofug.ro)
 ROFUG founder

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



RE: ping: sendto: No buffer space available

2003-02-06 Thread k.j.koster
Dear All,


 : --- if_ep.c Fri Feb  1 19:51:43 2002
 : +++ if_ep.c.fix Sat Feb  9 12:49:31 2002
 : @@ -571,7 +571,6 @@
 :  
 : if (status  (S_RX_COMPLETE | S_RX_EARLY)) {
 : epread(sc);
 : -   continue;
 : }
 : if (status  S_TX_AVAIL) {
 : /* we need ACK */
 
 Committed this, and a couple other touch-ups to current.

I haven't been experiencing these lockups, but since the most recent buildworld I seem 
to have it (once so far, doing a large ports build on an NFS mount to verify).

I looked at the code of if_ep.c and I see that the continue is indeed not there.

Here's the version of if_ep.c that I have:
$FreeBSD: src/sys/dev/ep/if_ep.c,v 1.95.2.3 2002/03/06 07:26:35 imp Exp $

This is a 3com Ethlerlink III pccard thingy, by the way.

angua% uname -a
FreeBSD angua.research.kpn.com 4.7-STABLE FreeBSD 4.7-STABLE #20: Thu Feb  6 12:12:56 
CET 2003 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/ANGUA  i386
angua% ifconfig ep0
ep0: flags=a843UP,BROADCAST,RUNNING,SIMPLEX,LINK1,MULTICAST mtu 1500
inet blotted out netmask 0xf800 broadcast 139.63.199.255
ether 00:60:08:23:20:5d
media: Ethernet 10baseT/UTP
angua% dmesg | grep ep0
ep0: 3Com Etherlink III 3C589 at port 0x240-0x24f irq 11 slot 0 on pccard0
ep0: Ethernet address 00:60:08:23:20:5d

Kees Jan

=
 You can't have everything.  Where would you put it?
 [Steven Wright]

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



RE: ping: sendto: No buffer space available

2003-02-06 Thread Dirk-Willem van Gulik


On Thu, 6 Feb 2003 [EMAIL PROTECTED] wrote:

 I looked at the code of if_ep.c and I see that the continue is indeed
 not there.

AFAIK it needs to be there; at least it solves the hangs I see here.

Dw


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



Can someone apply the patches in misc/42422 and misc/42429?

2003-02-06 Thread GB Clark
Hello,

I had submitted misc/42422 and misc/42429 over 5 months ago and am
going to try one more time to get them applied.

misc/42422 is a simple 4 line patch to lib/libc/db/ndbm.c and misc/42429 
is a 3 line patch to src/lib/libc/db/hash.c.

They both concern how the return values are in conflict with the man
pages.

Thanks for looking.

GB

-- 
GB Clark II | Roaming FreeBSD Admin
[EMAIL PROTECTED] | General Geek 
   CTHULU for President - Why choose the lesser of two evils?

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



Re: Anyone where to get a signed SSL certificate cheap?

2003-02-06 Thread Anti
On Wed, 5 Feb 2003 18:17:24 +
Josef Karthauser [EMAIL PROTECTED] wrote:

 I know that this is slightly off topic, but maybe someone here could
 advise me.
 
 I need to obtain a certificate to use on my openssl/apache web server,
 but looking at Verisign and Thawte it appears that they're charging a
 lot of money ($450) per year for one!  Does anyone know where I can get
 one cheaper?  Last time I bought I'm sure that they were only $100/yr
 each.


https://products.freessl.com/ssl/freessl.do




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



Re: Anyone where to get a signed SSL certificate cheap?

2003-02-06 Thread Philip Paeps
On 2003-02-05 18:17:24 (+), Josef Karthauser [EMAIL PROTECTED] wrote:
 I need to obtain a certificate to use on my openssl/apache web server, but
 looking at Verisign and Thawte it appears that they're charging a lot of
 money ($450) per year for one!  Does anyone know where I can get one
 cheaper?  Last time I bought I'm sure that they were only $100/yr each.

There are quite a few places willing to cell you certificates for $100 or
less, but the problem is that those usually cause big red error-messages to
pop up on the users' screen.

I buy my certificates from GlobalSign http://www.globalsign.com/, which
sells them to me for ¤175/yr.  Their root certificate is recognised by most
browsers I've encountered.

 p.s. yes, I know that I could self-sign, but this is for an ecommerce system
 and I'd prefer our customer's customers not to have to ask themselves why
 the certificate is in our name and not our customer's! :)

You'd have the same problem with the $100/yr certificates.  Most browsers
don't recognise them (bloody monopoly :-/) and pop up doomsday warnings...

 - Philip

-- 
Philip Paeps  Please don't CC me, I am
[EMAIL PROTECTED]   subscribed to the list.

  BOFH Excuse #199:
the curls in your keyboard cord are losing electricity.

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



unsubscribe

2003-02-06 Thread Ruslan Babayev


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



Bus error - FD or msdos HD mount

2003-02-06 Thread guillaume
hello,
since i get no answer in fr.comp.os.bsd, [EMAIL PROTECTED] , and
[EMAIL PROTECTED] , i'm trying here now, hoping i'm not too off-charter.

i can't mount my floppy disk and my Win98 hard disk.

i tape: # mount -t msdos /dev/ad0s1 /hdibm
or: # mount -t msdos /dev/fd0.1440 /floppy
(or with ad0c, fd0c, ...)

and i get Bus error and a core file.

my bootable Win98 disk (only 1 partition - FAT32, 12.6 Go) is
connected in master to the primary IDE.
my floppy is a classic 1.44 Mo and i want to read MSDOS formated
floppies.
of course i have the 2 special files in /dev, and i created the mount
directories.
i have access to these disks with fsck_msdosfs or disklabel.

i followed all the procedure to format and mount a new MSDOS
floppy disk but i always have this error.

i haven't these problems with my CDROM and my bootable FreeBSD
disk.

for information i can get the same error when i try to mount one of
my FreeBSD partition as a MSDOS partition
( # mount -t msdos /dev/ad3s1g /tmp ).

(i'm under FreeBSD 4.7)

does somebody know how to resolve this problem?

thank you!



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



SiS pciconf's request ending :)

2003-02-06 Thread Soeren Schmidt

Thanks to all those that replied with pciconf output from 
various SiS chipsets (and thanks to those that sent from
other systems as well :) ).
I now have a significant amount of data to use for the SiS
chipset support, and am working on it over the next days..


-Søren

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



¥Î¤ß¬Ý§¹³á!!!.....

2003-02-06 Thread slc12
Title: ¯¬±z¦Ï¦~






¯¬±z¦Ï¦~

 
¤@¦|­·¶¶¡B¤GÀsÄË­¸¡B¤T¦Ï¶}®õ¡B
 
 
¥|©u¥­¦w¡B¤­ºÖÁ{ªù¡B¤»¤»¤j¶¶¡B
 
 
¤C¬P°ª·Ó¡B¤K¤è¨Ó°]¡B¤E¤E¦P¤ß¡B
 
 
¤Q¥þ¤Q¬ü¡A¬v¬v±o·N¹L¦n¦~


 
 ³Ì¦³¬¡¤Oªº---¤pºµºµ







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


Making pkg_XXX tools smarter about file types...

2003-02-06 Thread Tim Kientzle
The attached patch modifies the pkg_install
tools to inspect the file contents--rather than the
filename extension--to determine the
compression method in use.  It then feeds the data
into the correct invocation of 'tar'.
I've also modified exec.c/lib.h to
factor out and expose some common code that
formats shell command lines.

This approach makes it possible, for instance, to
fix a single file extension (e.g. '.freebsd'
or '.package') that would not have to change
even if the internal format of a package were
to change (as has already occurred once, with
the transition from gzip to bzip2 compression).

Note that this could also be fairly easily extended
to support a variety of alternative archive
types.  (E.g., the pkg_XXX tools could be
modified to support 'zip' or 'tar' archives
transparently to the user.)

Tim Kientzle

P.S.  Similar logic should no doubt be
added to 'tar' itself, thus eliminating the
need for the -z/-j/-y options.

Index: lib/exec.c
===
RCS file: /usr/src/cvs/src/usr.sbin/pkg_install/lib/exec.c,v
retrieving revision 1.10
diff -c -r1.10 exec.c
*** lib/exec.c  2002/04/01 09:39:07 1.10
--- lib/exec.c  2003/02/06 19:05:28
***
*** 25,59 
  #include err.h
  
  /*
!  * Unusual system() substitute.  Accepts format string and args,
!  * builds and executes command.  Returns exit code.
   */
! 
! int
! vsystem(const char *fmt, ...)
  {
! va_list args;
  char *cmd;
- int ret, maxargs;
  
  maxargs = sysconf(_SC_ARG_MAX);
  maxargs -= 32;/* some slop for the sh -c */
  cmd = malloc(maxargs);
  if (!cmd) {
!   warnx(vsystem can't alloc arg space);
!   return 1;
  }
- 
- va_start(args, fmt);
  if (vsnprintf(cmd, maxargs, fmt, args)  maxargs) {
!   warnx(vsystem args are too long);
!   return 1;
  }
  #ifdef DEBUG
  printf(Executing %s\n, cmd);
  #endif
  ret = system(cmd);
- va_end(args);
  free(cmd);
  return ret;
  }
--- 25,83 
  #include err.h
  
  /*
!  * Format a command, allocating a buffer along the way.
   */
! static char *
! va_system_cmd(const char *fmt, va_list args)
  {
! int maxargs;
  char *cmd;
  
  maxargs = sysconf(_SC_ARG_MAX);
  maxargs -= 32;/* some slop for the sh -c */
  cmd = malloc(maxargs);
  if (!cmd) {
!   warnx(can't allocate memory to format program command line);
!   return NULL;
  }
  if (vsnprintf(cmd, maxargs, fmt, args)  maxargs) {
!   warnx(argument list is too long);
!   return NULL;
  }
+ return cmd;
+ }
+ 
+ char *
+ system_cmd(const char *fmt, ...)
+ {
+ va_list args;
+ char *cmd;
+ 
+ va_start(args, fmt);
+ cmd = va_system_cmd(fmt,args);
+ va_end(args);
+ return cmd;
+ }
+ 
+ /*
+  * Unusual system() substitute.  Accepts format string and args,
+  * builds and executes command.  Returns exit code.
+  */
+ int
+ vsystem(const char *fmt, ...)
+ {
+ va_list args;
+ char *cmd;
+ int ret;
+ 
+ va_start(args, fmt);
+ cmd = va_system_cmd(fmt,args);
+ va_end(args);
+ if(cmd == NULL) return 1;
  #ifdef DEBUG
  printf(Executing %s\n, cmd);
  #endif
  ret = system(cmd);
  free(cmd);
  return ret;
  }
***
*** 63,69 
  {
 FILE *fp;
 char *cmd, *rp;
-int maxargs;
 va_list args;
  
  rp = malloc(MAXPATHLEN);
--- 87,92 
***
*** 71,94 
  warnx(vpipe can't alloc buffer space);
  return NULL;
  }
! maxargs = sysconf(_SC_ARG_MAX);
! maxargs -= 32;/* some slop for the sh -c */
! cmd = alloca(maxargs);
! if (!cmd) {
!   warnx(vpipe can't alloc arg space);
!   return NULL;
! }
  
- va_start(args, fmt);
- if (vsnprintf(cmd, maxargs, fmt, args)  maxargs) {
-   warnx(vsystem args are too long);
-   return NULL;
- }
  #ifdef DEBUG
  fprintf(stderr, Executing %s\n, cmd);
  #endif
  fflush(NULL);
  fp = popen(cmd, r);
  if (fp == NULL) {
warnx(popen() failed);
return NULL;
--- 94,110 
  warnx(vpipe can't alloc buffer space);
  return NULL;
  }
! va_start(args,fmt);
! cmd = va_system_cmd(fmt,args);
! va_end(args);
! if(cmd == NULL) return NULL;
  
  #ifdef DEBUG
  fprintf(stderr, Executing %s\n, cmd);
  #endif
  fflush(NULL);
  fp = popen(cmd, r);
+ free(cmd);
  if (fp == NULL) {
warnx(popen() failed);
return NULL;
***
*** 97,103 
  #ifdef DEBUG
  fprintf(stderr, Returned %s\n, rp);
  #endif
- va_end(args);
  if (pclose(fp) || (strlen(rp) == 0)) {
free(rp);
return NULL;
--- 113,118 
Index: lib/file.c
===
RCS file: /usr/src/cvs/src/usr.sbin/pkg_install/lib/file.c,v
retrieving revision 1.64
diff -c -r1.64 

FWD: Re: mounting a pen drive

2003-02-06 Thread Craig Sebenik
In a nutshell, I have a usb pen drive that I can't mount.

4.7 seems to recognize it just fine. So, it must be some silly little 
thing I need to do.

Ideally, I would love to put a ufs filesystem on this thing as well.

Any pointers would be greatly appreciated.

TIA!
Craig

- Forwarded message from Daniel O'Connor [EMAIL PROTECTED] -

Date: 06 Feb 2003 14:27:53 +1030
From: Daniel O'Connor [EMAIL PROTECTED]
To: Craig Sebenik [EMAIL PROTECTED]
Cc: USB BSD List [EMAIL PROTECTED]
Subject: Re: mounting a pen drive
Content-Type: text/plain
Organization: 
X-Mailer: Ximian Evolution 1.2.0 

On Thu, 2003-02-06 at 13:08, Craig Sebenik wrote:
 I have looked briefly at the FAQ and at some of the other web pages and I 
 can't find an explanation for how to simply mount a pen drive.
  usbdevs
 addr 1: UHCI root hub, Intel
  addr 2: product 0x2001, vendor 0x121e
 
 I tried mounting the drive with:
 
  mount_msdos /dev/da0c /tmp/pen
 mount_msdos: /dev/da0c: Invalid argument
 
 
  dmesg | grep umass
 umass0: vendor 0x121e product 0x2001, rev 1.10/1.00, addr 2
 da0 at umass-sim0 bus 0 target 0 lun 0
 (da0:umass-sim0:0:0:0): READ(6)/WRITE(6) not supported, increasing minimum_cmd_size 
to 10.

Probably worth asking on a list like freebsd-stable or -hackers. A lot
of these devices need a quirk to function (ie they don't understand
certain commands and will hang)

If you get the quirk stuff sorted out, it should Just Work as a normal
disk.

-- 
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
GPG Fingerprint - 9A8C 569F 685A D928 5140  AE4B 319B 41F4 5D17 FDD5

- End forwarded message -

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



Re: Help with understanding process state, context switching and

2003-02-06 Thread Julian Elischer
 signals
In-Reply-To: [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

The only way it makes sense to talk about suspending
a process in user space from the kernel, would be in a MP system. in a
UP system, if you are in the kernel, then there is no process in user
space. (it trapped into the kernel whenever whatever interrupt that
stasrted you running happenned).  In SMP you may need to set some flag
and send an IP to all teh processes to ensure that the process enters
the kernel to see the flag.  Depending on what you wnat to do, it is
possible that ptrace (as DES says) is what you want, or maybe just a 
SIGSTOP will do.


On Thu, 6 Feb 2003, Dag-Erling Smorgrav wrote:

 Andrey Simonenko [EMAIL PROTECTED] writes:
  In short: I need to stop (suspend) some process from the kernel, when
  that process is in user mode and get information about its general-purpose
  registers, its VM structures, etc.
 
 Have you looked at ptrace(2)?  That's what gdb(1) uses.  You can get
 additional information about memory maps etc. from procfs.
 
 DES
 -- 
 Dag-Erling Smorgrav - [EMAIL PROTECTED]
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with unsubscribe freebsd-hackers in the body of the message
 


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