Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > How does fdentry.users work?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 11th April 03:11
kd
External User
 
Posts: 1
Default How does fdentry.users work?



I'm from Gaisler Research. We are trying to port Lynxos to the Leon-
sparc
platform. We have come quite far now, I can boot up, /init starts and
forks off /bin/dlsh. Here
comes the problem: the libc function getwd() goes into
a swait() when sys/kernel/read,c:close_fd() is called. Here is the
callpath:

src/lib/libc/getwd.c:getwd()
-> src/lib/libc/getwd.cpendirstat()
-> ...
sys/kernel/read.cpen()
-> sys/kernel/read.c:get_fd()

[ here fdentry index 5 is allocated. fdentry.users = 0 ]

sys/kernel/read.c:lseek()
-> sys/kernel/read_text.c:getf(5)

[ getf sets fdentry.users = 1 ]

-> sys/kernel/read.c:close(5)
-> sys/kernel/read.c:close_fd(5)
=> while (fdp->users != 0) { ...
if (swait(&currpptr->fdcsem, 1)) {

[ Here I enter swait ]

So here the question:

lseek() gets a fdentry and increments fdentry.users. It _doesnt
decrement_
fdentry.users on return and fdentry.users stays 1. Therefore the
following close() waits
on fdentry.users that is 1.

How is this supposed to work?

I cannot see a call to freef_fd() somewhere in the code. I suppost
that lseek should
call freef_fd() on return. What am I making wrong here ... ?

I'd apreciate your help.

-- Konrad
  Reply With Quote


  sponsored links


2 11th April 03:11
steve watt
External User
 
Posts: 1
Default How does fdentry.users work?



Caution: Extremely old neurons (I haven't been in the LynxOS sources for almost 9 years)...
I seem to recall that there's some magic about currtptr->fd (maybe it's
currfd?) where at system call return, if it's not 0 / -1 / something
invalid, a freef_fd() happens automatically.

So check in the syscal return trampoline code; it might be in there.
--
Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.5" / 37N 20' 15.3"
Internet: steve @ Watt.COM Whois: SW32-ARIN
Free time? There's no such thing. It just comes in varying prices...
  Reply With Quote
3 11th April 03:11
cyril novikov
External User
 
Posts: 1
Default How does fdentry.users work?


Yeah, if there's an fd in use, the syscall handler automatically releases it
before returning. That's why most syscalls that getf() don't have a matching
release.
  Reply With Quote
4 11th April 03:11
kd
External User
 
Posts: 1
Default How does fdentry.users work?


Hi,
Thanks, this makess sense. I'll investigate this path.
-- Konrad
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666