Jump to content
Science Forums

Finally learning C++!


Recommended Posts

So it just seems like what setting you want to put your zoom lens at to get your answer.

well, if you really get down to it, then the program gets stored as a series of 1's and 0's, but compiled code never gets executed as that, it is therefore given to the processor as a series of instructions that it then executes, yes those instructions have a binary representation, but nontheless, techically the code gets compiled into a form of assembly. hence why executables are processor arch speciffic.

 

Most all of it.
i am not sure you are aware of what an operating system is... lets start with basics, what is an OS :help:

 

The XP won't boot on that hardware because it requires 250meg minimum of RAM just to load.

once again, what is an operating system.... (trust me this is hopefully so you learn something new, so in your own words, before you look at wikipedia, and then in a separate section in you own words what wiki said it to be, and what you discovered....

 

i will preface your "Huh?" (the common starter of a small research), did you know that technically, on most any PC, you are running 2 operating systems at the same time, independent on which OS you come to believe you runt, technically there is always another OS that starts prior? (kudos if you guess this before looking up what an OS is (it is rather obvious, and yet so "Huh!!??-like"))

 

And I would love to have a product that was built with quality and efficiency

great, so you won't claim that the inefficient code becomes more efficient on better hardware ;) good, now to get you to understand the os efficiency, well, we start with what an OS is, then we'll go into the efficiency part of it :read:

Link to comment
Share on other sites

well, if you really get down to it, then the program gets stored as a series of 1's and 0's, but compiled code never gets executed as that, it is therefore given to the processor as a series of instructions that it then executes, yes those instructions have a binary representation, but nontheless, techically the code gets compiled into a form of assembly. hence why executables are processor arch speciffic.

 

i am not sure you are aware of what an operating system is... lets start with basics, what is an OS ;)

 

 

once again, what is an operating system.... (trust me this is hopefully so you learn something new, so in your own words, before you look at wikipedia, and then in a separate section in you own words what wiki said it to be, and what you discovered....

 

i will preface your "Huh?" (the common starter of a small research), did you know that technically, on most any PC, you are running 2 operating systems at the same time, independent on which OS you come to believe you runt, technically there is always another OS that starts prior? (kudos if you guess this before looking up what an OS is (it is rather obvious, and yet so "Huh!!??-like"))

 

 

great, so you won't claim that the inefficient code becomes more efficient on better hardware :eek: good, now to get you to understand the os efficiency, well, we start with what an OS is, then we'll go into the efficiency part of it :hyper:

 

Ok maybe a little background is in order. I have been programming since 1976 when I was 10. When I was 16 I disassembled the ROM on my TRS-80 Color computer with a disassembler I wrote myself from the 6809E manual that I bought with my allowance. I have hacked my first Apple ][E at 17. I have worked on things as small as a TI-88 on up to an MVS Z90 machine and several $60k SGI machines in between. I have written my own operating system, simulated the performance other operating systems under various paging size limits, and I consistently came in with fewer lines of code to accomplish the task than any of my fellow students. I have probably worked on over 2 dozen operating systems in as many years. I do not need wiki to tell me what one is or how it works.

 

The word you are looking for is a Kernel. And yes I am aware that any decent OS has one. I have helped bootstrap the Kernel several times on $50 million dollar machines at 3 o'clock in the morning with $17k losses per minute on the line.

 

The reason I am discussing OS's and compilers at various levels is because I am very familiar with them at all those levels, from source code, to tokenized p-code, to assembly, circuits and down to the transistors if we need to go that detailed.

 

I'm not sure what you are trying to accomplish with the pop-quizzes. If you would like to make a point then do so, otherwise please quit wasting time and pixels with obtuse and misspelled questions.

Link to comment
Share on other sites

kernel is not the word i was looking for, BIOS was the word, most simplistic OS that runs on mostly every PC. Every OS has a kernel btw, by definition :hyper:...

 

well, that intro puts me in my place.... i think i loose in every category there... i only know 27 programming languages, 3 of which are assembly, i play around with microcontrollers a fair amount, though recently it's been pbasic, but that's just because i passionately dislike java :hyper: I've built many customized versions of nix, and had a couple of LFS boxes, used to religiously run gentoo, and compiled every kernel for every machine i have had, and more ;) and i've only written a file system module for the linux kernel as a project, though i have programmed an 8085 microprocessor, a small spark-based processor and have written programs in x86 assembly and TI calculator assembly...

 

My ponderance about your credentials is in this: you claim that windows code is extremely inefficient, yet its really arguable with the windows kernel, they have been using some of the latest memory managers and apparently updated their network stack to be a lot more efficient(though fairly stupidly in my eyes), but never the less, windows has a lot of good code, and a lot of their kernel code is rather efficient at what it does. The interface is a different story, and the programs that come bundled is an even differenter different story...

 

the reason I am discussing OS's and compilers at various levels is because I am very familiar with them at all those levels, including the transistors if we need to go that detailed.

i likes transistors, you ever get bored enough to design a circuit for your own ALU?

 

besides, dont get bent out of shape with my questions, i never assume someone knows something till they answer ;)

 

so do i hear a "Huh?" coming with the BIOS? its a CS geek trivia question for 500, jk, but really not many people think about things like the BIOS as being an OS :eek:

Link to comment
Share on other sites

Do you two need a ruler to figure out which of you is, uh, bigger?

 

To lighten the mood, a reference to this came across Slashdot today:

 

 

C would be Judaism - it's old and restrictive, but most of the world is familiar with its laws and respects them. The catch is, you can't convert into it - you're either into it from the start, or you will think that it's insanity. Also, when things go wrong, many people are willing to blame the problems of the world on it.

 

Java would be Fundamentalist Christianity - it's theoretically based on C, but it voids so many of the old laws that it doesn't feel like the original at all. Instead, it adds its own set of rigid rules, which its followers believe to be far superior to the original. Not only are they certain that it's the best language in the world, but they're willing to burn those who disagree at the stake.

...

C++ would be Islam - It takes C and not only keeps all its laws, but adds a very complex new set of laws on top of it. It's so versatile that it can be used to be the foundation of anything, from great atrocities to beautiful works of art. Its followers are convinced that it is the ultimate universal language, and may be angered by those who disagree. Also, if you insult it or its founder, you'll probably be threatened with death by more radical followers.

Click the link to read the whole thing....hilarious! :QuestionM

 

Have you heard this story of the Hot Rod Race, when Fords and Lincolns was settin' the pace? That story is true, I'm here to say I was drivin' that Model A, ;)

Buffy

Link to comment
Share on other sites

kernel is not the word i was looking for, BIOS was the word, most simplistic OS that runs on mostly every PC. Every OS has a kernel btw, by definition :rolleyes:...

No. Most all current OS's have a Kernel. Most of the older OS's such as DOS and Windows 3.11 talked directly to the hardware. It was only after MS hired the writer of VAX to write NT that the concept of a Kernel was added to the PC. The various OS's on the TRS-80s, the Apples prior to Mac, the Commodore etc all talked directly to the hardware. Consequently the OS has to be updated with new hardware.

 

And BIOS is an anomalous hack of poorly designed PC's, not any of the other machines out there. A technological afterthought. Just like the Windows Registry.

 

well, that intro puts me in my place.... i think i loose in every category there... i only know 27 programming languages, 3 of which are assembly, i play around with microcontrollers a fair amount, though recently it's been pbasic, but that's just because i passionately dislike java :) I've built many customized versions of nix, and had a couple of LFS boxes, used to religiously run gentoo, and compiled every kernel for every machine i have had, and more :) and i've only written a file system module for the linux kernel as a project, though i have programmed an 8085 microprocessor, a small spark-based processor and have written programs in x86 assembly and TI calculator assembly...

Yes I have you beaten on all language and technology counts. But why does that matter here?

 

i am not sure you are aware of what an operating system is... lets start with basics, what is an OS

 

I don't know why this conversation motivates you to ask about simple technology definitions. What bearing on this conversation does it have that I understand BIOS, TCP, EPROMS, SQL, MAPI, LU 6.2, Encryption, Fuzzy Logic, CASE, EIS, ODBC, COM, DCOM, OOP, RUP or any of the other dozens of technologies acquired over the years?

 

Buffy is (humorously) right. And I am done with this conversation.

Link to comment
Share on other sites

By your count Alexander, I find myself holding no less than Three OSes. CMOS, BIOS, and WinXP(which might technically be more than one OS itself).

 

The two OSes I interact with are the BIOS and WinXP. The CMOS does it's own thing until POST has finished, if I am on my mark, at which point control is handed to me via the BIOS or, if I decline to grab the reigns,.via WinXP.

 

Perhaps, I should wait for the argument by verbosity to die down before I start asking questions about emergent properties of generative languages and metalanguages?

 

I dig the "it uses more cycles" part of the equation. Thanks for the tip about variable declarations. I'll keep that algorithm in my toolbag for future optimization. I am curious though, what about when a language gives up raw processing power to gain new modes of behavior? Surely, you see the value of C compared to Assembly, of C++ compared to raw C, of Ruby compared to C++?

 

Each step up the ladder gives us new ways we can express solutions which are impossible without the metalevel frameworks. Perhaps at the cyclical/individual-processor level we lose efficiency, but what about at the programmatic/user level?

Link to comment
Share on other sites

No. Most all current OS's have a Kernel. Most of the older OS's such as DOS and Windows 3.11 talked directly to the hardware.

An operating system, by definition is a kernel, DOS had a kernel just like any other modern OS, and windows 3.0 was a program that ran on top of dos to provide a gui.

 

Definitions (source=wiki)

 

Operating system: it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer.

 

Kernel: kernel provides the lowest-level abstraction layer for the resources (especially memory, processors and I/O devices) that application software must control to perform its function.

 

on to my original point about bios:

 

BIOS is an operating system in its simplest form, it provides abstraction between hardware calls and the OS kernel calls for hardware, it determines what hardware you have and gives the kernel a somewhat uniform way to talk to it, this is especially the case for hard drives. The only reason i say that most modern computers have it, because EFI (used by macs) is a slightly different system.

 

KAC, don't confuse hardware design, such as CMOS with software, like BIOS.

 

CMOS is a circuit design that uses p and n-type transistors to create logic gates. the use of p and n-type transistors reduces the amount of power usage of such a chip, as well as the heat generated by such a chip, because the MOSFETs only use power to switch states.

 

BIOS is Basic Input Output System, though recently, more and more it's been called Built In Operating System. i think wiki hits it on the spot with:

refers to, in part, the firmware code (a type of boot loader) run by a PC when first powered on. The primary function of the BIOS is to identify and initialize system component hardware (such as the video display card, hard disk, and floppy disk) and some other hardware devices. This is to prepare the machine into a known low capability state, so other software programs stored on various media can be loaded, executed, and given control of the PC.[2] This process is known as booting, or booting up, which is short for bootstrapping.

 

But why does that matter here?

Lol, i dunno, i'm just being a pain in the ***, that's all :eek:

 

I don't know why this conversation motivates you to ask about simple technology definitions.

because you said that windows is an inefficient piece of code, and i digress, simply because they use current day memory managers, semi-optimized tcp stack, an ok, bloated, but by design, fairly efficient as a piece of code kernel.... and i asked you about which part you meant to be inefficient, and you said all of it, which is a simple and generic answer that any 15 year old script kiddie would and has counlessly given me, because they don't have any clue as to what they are talking about, i wanted to make sure we are on the same level by asking a very simple question; windows is not a simple, nor single piece of software :turtle:

Link to comment
Share on other sites

how many algorithms can you come up with for this simple probllem:

 

you have 2 values: A and B

your task is to change the values around so that B becomes the value of A and A becomes the value of B

 

inial values if you need them

A=5

B=7

 

When you post your algos please note ticks and memory advantages and disadvantages

Alexander,

 

Sorry I missed this last week. Let me play. An old trick I used in C (w/o temp var).

 

[font=Courier New][color=Green]/* Let A = 5 & B = 7 */
[/color][/font][font=Courier New][color=Blue]A ^= B ^= A ^= B;
[/color][/font]

 

In C (or C++) you can assign with successive assignment statements as above.

Say for example we are only computing in 4 bits %1111 or f in hex.

So A = 5 = 0101 & B = 7 = 0111.

Reading from right 0101 ^ 0111 -> 0010 put that in A.

0111 ^ 0010 -> 0101 put that in B.

Remember A is now 0010 so

0010 ^ 0101 -> 0111 put that in A.

So now at the end B = 5 & A = 7

Viola !!!

 

So I really can do it in one line -- this works for all values of type {int} format

be it 16b, 32b, 64b. :shrug:

 

maddog

Link to comment
Share on other sites

  • 2 weeks later...
hehe, i wonder if you can use binary operations on pointers... nope.... darn that would be nice <- :)

As for binary ops on pointers ... hmm... let me think ...

 

How about

 

#define BadPointer 0xdeadc0de

 

void* p;

 

... later

 

int safevalue;

 

safevalue = (p == 0 ? BadPointer: *p);

 

 

I am not sure if this was what you were thinking wrt binary pointers --

They are either good or not. :alien_dance:

 

:winter_brr: :) :naughty:

 

maddog

Link to comment
Share on other sites

An operating system, by definition is a kernel, DOS had a kernel just like any other modern OS, and windows 3.0 was a program that ran on top of dos to provide a gui.

 

Definitions (source=wiki)

 

Operating system: it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer.

 

Kernel: kernel provides the lowest-level abstraction layer for the resources (especially memory, processors and I/O devices) that application software must control to perform its function.

 

Taken out of context that works great. However if you included the first half of wiki's definition it makes my point - the kernel is a sub component of the OS, not the whole OS itself. It allows the same OS to run unchanged on top of various hardware.

 

As a basic component of an operating system,
a kernel provides the lowest-level abstraction layer for the resources (especially memory, processors and I/O devices) that application software must control to perform its function.

 

 

 

Lol, i dunno, i'm just being a pain in the ***, that's all :turtle:

Thanks for the clarification. I thought you were just being an ***.

 

because you said that windows is an inefficient piece of code, and i digress, simply because they use current day memory managers, semi-optimized tcp stack, an ok, bloated, but by design, fairly efficient as a piece of code kernel.... and i asked you about which part you meant to be inefficient, and you said all of it, which is a simple and generic answer that any 15 year old script kiddie would and has counlessly given me, because they don't have any clue as to what they are talking about, i wanted to make sure we are on the same level by asking a very simple question; windows is not a simple, nor single piece of software :confused:

Yeah... like I said...

Link to comment
Share on other sites

the kernel is a sub component of the OS

 

It's statements like that that make me cringe...

 

here is the full definition of an OS:

 

Operating System is the infrastructure software component of a computer system; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer. The operating system acts as a host for applications that are run on the machine. As a host, one of the purposes of an operating system is to handle the details of the operation of the hardware. This relieves application programs from having to manage these details and makes it easier to write applications.

 

By definition an Operating System in its simplest terms, is a Kernel, nothing more, nothing less, please state what it is in the definition that points to behavior that is not provided by a kernel. I agree that most operating systems are useless without software that comes bundled with the kernel, a boot loader, and some sort of an interactive interface, etc, BUT an operating system, in the simplest of terms, is a kernel, the rest of the software, while bundled with most OSes, is not a make-up part of an OS, please refer to the OS and Kernel definitions...

 

Thanks for the clarification. I thought you were just being an ***.

i tend to be a pain in the ***, when it comes to technicalities.... but only because i actually care, as long as you dont hold a grudge against me, nothing personal at all. i mean if we met, you'd slap me, i'd slap you, and we'd spend the next 15 hours talking total geek, like normal people :doh: oh wait, without normal people stuff :)

Link to comment
Share on other sites

It's statements like that that make me cringe...

 

here is the full definition of an OS:

 

Operating System is the infrastructure software component of a computer system; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer. The operating system acts as a host for applications that are run on the machine. As a host, one of the purposes of an operating system is to handle the details of the operation of the hardware. This relieves application programs from having to manage these details and makes it easier to write applications.

[...]

 

 

I smell a new thread.

Link to comment
Share on other sites

  • 2 weeks later...
here is the full definition of an OS:

 

Operating System is the infrastructure software component of a computer system; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer. The operating system acts as a host for applications that are run on the machine. As a host, one of the purposes of an operating system is to handle the details of the operation of the hardware. This relieves application programs from having to manage these details and makes it easier to write applications.

 

By definition an Operating System in its simplest terms, is a Kernel, nothing more, nothing less, please state what it is in the definition that points to behavior that is not provided by a kernel. I agree that most operating systems are useless without software that comes bundled with the kernel, a boot loader, and some sort of an interactive interface, etc, BUT an operating system, in the simplest of terms, is a kernel, the rest of the software, while bundled with most OSes, is not a make-up part of an OS, please refer to the OS and Kernel definitions...:)

Sorry to through a monkey wrench into this one, though -- ughh, neither one of you have it completely I think.

 

For all the OS's (Operating Systems) I have use there is its Kernel and there are the secondary set of processes that interact with the Kernel. This is more exact (and clear) when you speaking about an RTOS (Real-Time Operating System) like Green Hills Integrity or Wind River VxWorks. So you think of the

kernel like it's origin like a wheat kernel -- a seed.

 

In RTOS's it is clear this at Ring0 is just the Round-Robin (or whatever method you use) Event Queue by which processes or tasks are scheduled to run and executed.

 

Where Symbology was using a Windows example (at least for NT I know) the Kernel you were thinking was the HAL portion -- though the same thing.

 

I think where this gets muddied up (& It is dirty) is like in the GHS example of Integrity you build all the resources you want into the OS you wish to deliver and compile / build it into a kernal. This is loaded by a bootloader on poweron and task are thereafter spawned from there afterwards. Maybe a new term should be invented.

 

Where I think Windows deviates (at least I haven't found it) no such file is loaded like that. Most RTOS do. MacOS X has a MachKernel with a linux like layer around it and MacOS X GUI around that. Unix had a Kernel, etc.

 

maddog

Link to comment
Share on other sites

Event Queue by which processes or tasks are scheduled to run and executed

the Event Queue, whether round-robin, preemptive, or EDF or a combination of thereof is a subpart of a kernel, kernel is responsible for process handling, memory management, low-level io operations, process resource allocation, file system, etc, etc. RTOS is still an os, still runs some form of a kernel... In plainest terms, no matter what the os, as long as there is a shell (in whatever form), there's some form of a kernel (get it, kernel, shell.....)

 

OS X is actually not RTOS, though i am not sure if you said that, or if i didn't understand you...

 

OS X actually runs XNU kernel (developed by Steve's buddies at NeXT, its a mach 3 microkernel with BSD process model, network stack and VFS, and I/O Kit (really nice device driver framework)). It's not a linux-like layer, its unix subsystem in its purest form with a microkernel at the base and brilliant OO device management, all wrapped in an Apple GUI (sounds like a pie recipe or something)) :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...