Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C Kernel, how do I execute external files!? 1

Status
Not open for further replies.

DevPortal

Programmer
Jul 8, 2005
40
0
0
US
I'm writing an OS, called SerpentOS. It will be booted from a floppy (with option to install to HDD). The bootable part is done, it boots into protected mode with A20 gate enabled, and starts a C kernel. Can someone supply me with some code to:

1. List files in a specific location.
2. Execute a file (.com, .exe, etc. (one type would be sufficient))

With these I intend to make two functions in the core of the kernel which will list contents of a directory you type, and execute a file you enter. This will provide very basic OS functionality, and I can then move on to add rename/delete/new functions, and then finally write programs for my own OS ^-^.

Thanks to whomever helpz..
~DevPortal
 
What is it: C kernel?
Is it a joke?..
 
a kernal written in C of course

jeez!!!

tomcruz.net ;-)
 
bill gates is trembling in his penny loafers

tomcruz.net
 
Yes... Add everything else to the kernel: start from disk drivers then implement file system layer then we all try to help you to debug your directory scanning utilite (if you are planning to port C library and present exe loader to the new OS)...
 
How does one go about creating a file system? The disks are formatted in FAT12, is it possible to just put files on the disk normally and call them using built in functions?...

All the tutorials I ever find on C just give you the basics. User input, screen output, and LOADS of math functions. However, I need to learn how to do the more advanced stuff. You say "make your filesystem layer and then we'll help you make your directory utilities", but I've a problem in that I don't know how to go about the first steps >.<

Where can I go to learn advanced C stuff such as this?
 
It's not advanced C stuff, it's operational system design and development area.
C run-time library obtains file i/o services from underlying operational system. C library i/o functions do not know anything about FAT32, NTFS, Unix file descriptors etc.
C run-time library obtains memory from the underlying OS memory managers etc.
Ask OS forums, but better read books about OS...
 
DevPortal,

Please don't take this the wrong way ...

While I persoanlly would find it rather interesting to attempt to write an OS (as an intellectual excercise), I would not even consider doing it, because I just do not have the skills or knowledge yet(I have been programming C solidly for a year, and Java for 4 years).

Maybe you should step back a bit, and try to write something a bit more managable, like an FTP server and client, or maybe an HTTP server. These will teach you a lot of skills, but are not impossible to do.

I think if you have to come onto sites like tek-tips to ask how to do stuff, then you *generally* shouldn't be trying to write an OS, as you clearly just don't have the skillset.

Best of luck.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
DevPortal,

I agree with what sedj says. You're biting off more than you can chew. Just based on your other post asking "What do the little asterisk tokens do??", you've got a lot to learn before you should really attempt to write an OS.

If you jump into writing something as complex as an OS, you're just going to get frustrated. Pick a smaller project and dig in. Each project try to learn something new. Start simple, maybe just write a utility to open and manipulate files some how. Then maybe do something that creates a nice display (curses or X). Then something that uses interprocess communication. Then something that does network communication with sockets or RPCs. Play with shared memory. Add to your skillset a little at a time and you'll gain the tools to do just about anything.

A couple jobs back I was on a team that wrote a multi-tasking OS kernel in C and assembler for an embedded system. It's NOT a beginner project to learn C on.

If you want to see what an OS looks like from the inside, go get the source for Linux. It's just a free download from quite a few different sites online. You can look through it and see the kinds of things an OS needs to do. If you can understand it, that's a great first step.

Hope this helps.
 
The bootable part is done, it boots into protected mode with A20 gate enabled, and starts a C kernel.

he's a gick study.

give the guy some credit. I dont know how to do that and
I am on my 7th year coding.

maybe he's the one.;-)

you keep the OS project in mind as you grow in the code
and in the end you may indeed rival gates or torvalds.

looking forward to your OS.

tomcruz.net
 
I have about 6-7 years experience writing in a variant of C. Much much simpler, designed for writing games only. I've written everything from network shooters (top down), first person zombie killing games, RTS games, and Windows shells (All of which are the more advanced things to make in this language, and Windows Shells are far beyond the normal context of this program, heh). I've extensive experience there, and it is based on C, so it is extremely similar. I'm awaiting the other half of my two-man programming team to return from his vacation so I can enlist his help to try to master C :D. Anyway, whenever he comes back, hopefully I can make some headway on this OS..

Oh and btw, if anyone would like to see any of the stuff I've made, I post my betas, etc., on my website (still under construction), ...
 
I was going to suggest writing a unix shell first and still
think this is a good idea.
What you are attempting is extremely non-trivial and
though I applaud your efforts I suggest you dissect each
piece of a unix like kernel first, then it's fundamental userspace parts, and examine how they work together.
 
I guess some of us have perhaps misjudged the "Skillset"
of this particular programmer. and I think it will show
that we all have our particular areas of expertise. and
our own weakness's. I do not understand how a programmer
code for several years and not understand pointers but I
do not have a crystal ball and cannot read minds either.

perhaps your variant has shielded you from the dirty
aspects of the art.

its time to read "C for dummies" and I am not making a
joke. this is a very good book and i will assume you need
to expand your horizons. if I am correct in assuming you
have not actually learned C but instead your variant of C
which is probably a subset. if I am mistaken I apologize.

dont listen to the naysayers, just plod on. just because
they could not does not mean you cant. if I had
listened to everyone who had told me I couldnt do this or
that I would not go anywhere. I am sure you understand the
magnitude of your project. as I am sure you are realistic in your goals.

and an aside from every thing else the lack of code
examples and responses is perhaps reflective of the
lack of OS coding skills in this forum and perhaps
this is not the place to look for answers to this
particular problem.

please no one take that as a personal assualt, just
perhaps a reality and a practise in humility.

tomcruz.net

 
Any of the 'for dummies' books have no place in
a valid conversation on programming in C. Anyone
who believes otherwise is living in la-la land.

Stevens is the standard for *nix programming.
Pick up the network and advanced texts & K&R
'The C programming Language", then work through
the examples, and you will be able to do most
C programming in a *nix or *nix like environment
acceptably.

Also: Simply perusing the comp.lang.c and
comp.programming.unix lists are far more
valuable than reading 'for dummies' texts.

 
and I suppose any one who needs an intro to
pointers should just jump right into
kerny and richy

and as a matter of fact I do live in my own
private world. as do most people who have an
"education" and believe that any one who is
doing it otherwise is wasting there time.
that explains why the engineers that build
the chemical plants that I work in, are constantly
screwing things up and the fact that if the
"genius's" who are in nasa were so smart we would
already be on mars. not to mention the fact that if
your nix were so great it would be mainstream.

by the way, I am self taught and I started with the
dummies. I may not be as fluent as some of you but
I am quite good in the code area that I work in.

isnt it alqaeda who says it so succintly;

"my way or the highway" boom.........

sincerely your's
and sorry for the stepping on the toesy's

tomcruz.net
 
I'm sorry you disagree, and disagree in so animated
a fashion. I'm sorry that you feel that anything you
have to say could discomfit or correct me in any way.

In way of explanation: I have worked through the exercises
in K&R and Stevens and have explored the pthreads model
in various real world exercises.
If you have a question regarding actual *nix C programming
I'm sure I can help you with experiential solutions, otherwise
you are the naysayer and need to step outside your own 'dummies' envelope....
 
When I started to learn C a year ago after a solid commercial Java background, the first book I read was K & R - and I can honestly say it was fantastic. Who better to explain the C programming lanaguage than the authors ?! No "dummies or SAMS" book is going to be able to top that.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I am right
you are wrong
any questions

if you only were as understanding as I am
you would believe everything i believe.

kinda humble that statement is

who said dummies was an end all any way?

you guys are so stuck on yourself
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top