OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:29 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Segmented VFS: Is this a good design?
PostPosted: Fri Apr 14, 2023 3:58 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 20, 2011 2:01 pm
Posts: 110
rdos wrote:
bellezzasolo wrote:
I think that is ok, but you shouldn't export class structures between kernel & userspace. Handles are a kind of object reference, and in my design, operate a bit like objects. I have some 20 different handle types that maps closely to userspace classes. In my classlib, I actually provide C++ classes for userspace to make the OO integration better. However, the syscall interface use a handle to identify the kernel object, and then pass parameters in registers. The userspace object pointer is not sent to kernel space since it easily changes and becomes incompatible.

This way of implementing an OO interface has some definite advantages. It particularly enforces encapsulation since userspace doesn't have access to internal object fields, and these can only be updated with proper methods through syscalls.

I think under the hood COM works much the same way - after all, when an application calls a method on a COM object, that object can be in a different process, so the actual implementation is a proxy class that marshalls the call through an IPC mechanism - indeed its possible to use over a network!

Implementation across the kernel boundary probably ends up sharing very similar concepts.

My thought with doing it that way is that you can offer the same API to kernel mode as to user mode - obviously access control needs doing. Whether you could implement user mode drivers the same way is a tantalising question, hopefully I'll get to explore it!

_________________
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS


Top
 Profile  
 
 Post subject: Re: Segmented VFS: Is this a good design?
PostPosted: Fri Apr 14, 2023 7:08 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
bellezzasolo wrote:
I think under the hood COM works much the same way - after all, when an application calls a method on a COM object, that object can be in a different process, so the actual implementation is a proxy class that marshalls the call through an IPC mechanism - indeed its possible to use over a network!


Indeed. If you create a microkernel, then there is a natural IPC barrier that syscalls go through. The kernel side objects then are stored in server processes. In a monolithic kernel, the handle concept is probably better as then the objects are mapped in shared kernel memory.

bellezzasolo wrote:
My thought with doing it that way is that you can offer the same API to kernel mode as to user mode - obviously access control needs doing. Whether you could implement user mode drivers the same way is a tantalising question, hopefully I'll get to explore it!


In my design, most user mode syscalls are usable in device-drivers too. The only exceptions are syscalls related to user process handling that has no meaning in kernel mode.

As for access control, I don't have user accounts, and so access control has no meaning in my OS. Which is interesting once I get to implementing ext and ntfs, as then I can just ignore file & directory permissions and show everything. :-)


Top
 Profile  
 
 Post subject: Re: Segmented VFS: Is this a good design?
PostPosted: Sun Apr 16, 2023 8:33 am 
Offline
Member
Member

Joined: Sun Apr 21, 2019 7:39 am
Posts: 76
Something similar is already being done by Windows NT.

There is an internal "object namespace" whose structure is very unix-ish, for example, "\Device\HarddiskVolume1" is a valid path within the NT object namespace. This is, however, only exposed as say, C:, in the Win32 APIs.

_________________
Hey! I'm developing two operating systems:

NanoShell --- A 32-bit operating system whose GUI takes inspiration from Windows 9x and early UNIX desktop managers.
Boron --- A portable SMP operating system taking inspiration from the design of the Windows NT kernel.


Top
 Profile  
 
 Post subject: Re: Segmented VFS: Is this a good design?
PostPosted: Mon Apr 17, 2023 4:41 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
iProgramInCpp wrote:
Something similar is already being done by Windows NT.

There is an internal "object namespace" whose structure is very unix-ish, for example, "\Device\HarddiskVolume1" is a valid path within the NT object namespace. This is, however, only exposed as say, C:, in the Win32 APIs.


There is no c:\device path in my Windows 10 at least, but I suppose they want to hide this from end users.

OTOH, devices were already added to the FS in MSDOS, so I don't see the news value in it. And things like comports are opened using special pathnames.

However, it doesn't surprise me that they "steal" bad ideas from Unix. I've completely removed the DOS device file support, and I'm not adding any new support for devices in file systems. Bad ideas should rest in peace.

BTW, I'm not going "everything is a file" either. That would be contrary to my "handles refers to objects" idea, unless I imply that all objects needs to have read/write methods, which certainly is not the case.

I even "ditch" the read method in my new filesystem as it would be a slow version of doing syscalls when they are not necessary. The new way to handle files is to issue map requests, not to issue read requests.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group