Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Aug 1999 13:34:51 -0600
From:      Charles Randall <crandall@matchlogic.com>
To:        Charlie ROOT <root@sani-c.vrn.ru>, freebsd-questions@FreeBSD.ORG
Subject:   RE: System hang when mmap() large files
Message-ID:  <64003B21ECCAD11185C500805F31EC0303786B03@houston.matchlogic.com>

next in thread | raw e-mail | index | archive | help
Are you running the machine out of swap? Looks like you mmap 10 new MB on
each iteration. What happens if you munmap() the region before the close()?

Charles

-----Original Message-----
From: Charlie ROOT [mailto:root@sani-c.vrn.ru]
Sent: Tuesday, August 10, 1999 1:53 AM
To: freebsd-questions@FreeBSD.ORG
Subject: System hang when mmap() large files



My FreeBSD 3.1-STABLE hangs when this small program running:
 
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
 
main()
{
    int fd;
    int i;
    int len=1024*1024*10;  /*ie 10Mbytes*/
    caddr_t addr;
    char ttt[80];

    for (i=0;;i++)
    {
    sprintf (ttt,"%d",i);
    fd=open(ttt,O_CREAT|O_RDWR,0666);
    if (fd<0)
    {
	printf("open error %ld\n",errno);
	exit(1);
    }
    lseek(fd,len-1,SEEK_SET);
    write(fd,"",1);
    addr=mmap(0,len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
    if (addr==MAP_FAILED)
    {
	printf("mmap error %ld",errno);
	exit(1);
    }
    close(fd);
    memset(addr,'x',len);
    }
}

uname -a on my machine shows:

FreeBSD oleg.sani-c.vrn.ru 3.1-STABLE FreeBSD 3.1-STABLE 
#2: Fri Apr 23 13:31:08 MSD 1999     
root@oleg.sani-c.vrn.ru:/usr/src/sys/compile/KERNEL-CURRENT  i386

Is this a known bug ? I'm very sorry, but I can't cvsup now, so if this
bug has been fixed already, please don't beat me, OK ? ;-)



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64003B21ECCAD11185C500805F31EC0303786B03>