LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2003, 09:50 AM   #1
corn
Member
 
Registered: Jan 2003
Posts: 46

Rep: Reputation: 15
How to make C librairies


Hello all,

Im new to C and i have to make a OS simulator using C. I definetly have to build some librairies that mimic CPU, scheduler, dispatcher, etc , but the thing is i dont know how under C. I would be glad if someone could help me out or at least point me to a tutorial on the web


Thanks in advance
 
Old 02-05-2003, 10:20 AM   #2
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
There is an article on user mode linux here. < http://www-106.ibm.com/developerworks/linux/ >

I also know that IBM was the first people to build a virtual machine. In theory I think that a virtual machine runs ontop of the hardware architecture - underneath the operating system kernel, so you might need to know about your microprocessors (Intel X86) hardware specification. The other part of the virtual machine runs in user mode. It simulates processes of the kernel in user mode. The processes are called virtual kernel and virtual user mode.

One good book about the theory is Operating System Concepts 6th edition. I read about half the book before I was distracted by something and had to quit but it talked about things like CPU sceduling, wait queues, signals, etc.

I would be interested in working on something like this myself but I would need to read more books.
 
Old 02-05-2003, 11:08 AM   #3
corn
Member
 
Registered: Jan 2003
Posts: 46

Original Poster
Rep: Reputation: 15
Id suggest for reading: Modern operating systems by Tanenbaum (im not sure if its spelled right). This gay is a former professor of Mr. Linux hismelf... the book is pretty complete.

I have pretty all the details to build the project i just dont know how to make librairies... i would not have this problem using objet-oriented programming but i dont have time to learn c++ and there is no pointer in java...


 
Old 02-05-2003, 11:36 AM   #4
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
You mean you don't know any C or C++? For example:
Code:
struct table
{
  int status;
  ...
};
Have you used gcc/g++ before?
 
Old 02-05-2003, 11:57 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,386

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
c++ is object orientated.....
 
Old 02-05-2003, 12:29 PM   #6
corn
Member
 
Registered: Jan 2003
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
This gay is a former professor of Mr. Linux hismelf
i meant guy!

of course i know C

example: tydef struct elem {
int PID;
int PRI;
int TT;
int IO
int ACCESS_NUM;
int ACCESS_CODE;
...
} PCB

yeah... i just want to make a header file so i can make abstract data types
 
Old 02-05-2003, 12:32 PM   #7
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
Put the definitions in a .C file and just have declarations in the .h file. The definitions have to be compiled and the .h is just a text file.

As far as I know! BTW I'd be happy to help you with the code: trollking@shaw.ca
 
Old 02-05-2003, 12:35 PM   #8
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
Well lets get some more code going and than we can see what is really happening. Can you use C++ rather than C?
 
Old 02-05-2003, 12:38 PM   #9
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
I mean technically to make a header file you just name the file with a .h extension:

Code:
#ifndef _MYLIB_H
#define _MYLIB_H

//declarations
#endif
 
Old 02-05-2003, 12:38 PM   #10
corn
Member
 
Registered: Jan 2003
Posts: 46

Original Poster
Rep: Reputation: 15
i could use... and i think it would be easier... since i could juste create objects as scheduler.... but i dont know how to program in c++... methods would be sooooo helpful lol...
 
Old 02-05-2003, 12:40 PM   #11
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
Do you know Java, because C++ and Java syntax is very similar.
 
Old 02-05-2003, 12:40 PM   #12
corn
Member
 
Registered: Jan 2003
Posts: 46

Original Poster
Rep: Reputation: 15
Btw thanks for the tip... if i understand correctly i only type the function prototypes in the .h files and the complete definitions in the .c files...
do i need both files to compile so the compiler can verifiy the integrety of the definittions??
 
Old 02-05-2003, 12:41 PM   #13
corn
Member
 
Registered: Jan 2003
Posts: 46

Original Poster
Rep: Reputation: 15
yeah i do know java... but a java OS would be too easy... i think embedded os's will be java like... and there is no pointer in java
 
Old 02-05-2003, 12:44 PM   #14
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
In the .cpp or .c files that define the objects declared in the .h files you include the header:

Code:
#include<iostream>
#include "mylib.h"

int main() {
  ...
  return 0;
}
If you want to share some of the implementation details, I'll help you build a few of the objects. I'm just a student, I don't work for any software company.
 
Old 02-05-2003, 12:51 PM   #15
corn
Member
 
Registered: Jan 2003
Posts: 46

Original Poster
Rep: Reputation: 15
Ahhh now thats all clear,

Thanks for the offer.. but im a student too... thats a project i have to finish in one month... and i have a partner already but if you want i can post the project requirements just for fun... or maybe youd want me to post the code?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
package compiling from source, make & make install concepts shujja Linux - Newbie 2 09-20-2005 12:18 AM
Chap 5 Binutils make LDFLAGS & make install errors shotokan Linux From Scratch 5 04-10-2005 03:01 AM
I accidentally deleted make file in /usr/local/bin, now cannot use make command.... Niceman2005 Linux - Software 2 11-17-2004 07:55 PM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM
make dep,make clean,make bzImage problem Babba Linux - Newbie 2 01-08-2003 03:49 AM


All times are GMT -5. The time now is 09:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration