DragonFly BSD
DragonFly commits List (threaded) for 2006-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/sys/conf files src/sys/kern init_main.c kern_acct.c kern_exit.c kern_fork.c kern_plimit.c kern_resource.c kern_synch.c syscalls.master src/sys/sys kern_syscall.h proc.h resourcevar.h

From: David Xu <davidxu@xxxxxxxxxxx>
Date: Wed, 24 May 2006 11:34:11 +0800

Matthew Dillon wrote:
    All the LWPs share one limits structure (since the limits structure
    is embedded in the process, not the lwp).   But this limits structure
    might have been inherited from other unrelated processes when the
    threaded program was fork/execed.

    When a process tries to create a second LWP (in the future, when that
    function is supported), the limits structure needs to be disconnected
    from those other unrelated processes so the threaded process has sole
    ownership of it.

    If we don't do this, then any LWP trying to modify a resource limit
    would have to perform the copy-on-write to replace the process's
    p_limits structure in the face of other LWPs potentially also accessing
    proc->p_limits.  We would have to obtain a spinlock on the process
    AND the limits structure to prevent a race.

    But if when a process tries to rfork a second thread we unshare the
    limits structure from other unrelated processes, now proc->p_limits
    is set in stone and all LWP threads will only have to spinlock
    the limits structure (and not have to spinlock the proc structure to
    get to the limits structure).

So that rule greatly reduces code complexity.

Matthew Dillon <dillon@xxxxxxxxxxxxx>

Thanks, I misunderstood your commit log.

David Xu

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]