Tag Archives: linux

Off on a Tangent: Calling Conventions

There are many things that we take for granted when using a computer: the operating system, hard ware drivers, and graphical interfaces. By learning about these tools, it gives a new awareness into how much work it takes to get even a simple system working. Computer programmers also take advantage of a number of software components: compiler, linker, operating system, memory management functions and debuggers. There is quite a bit of behind the scenes that goes on even in a simple program like:

int foo(int a, int b) {
return a + b;
}
int main() {
return foo(3, 4);
}

Still has many layers underneath the obvious, the one I want to mention briefly today is the calling conventions. I was curious what happens when you call a function, and looking on wikipedia, I found an article that very nicely shows how many possible things could happen.

Normally in with gcc, when you call a function, the generated code pushes the arguments to the function onto the stack in reverse order, that is, last argument first, and then pushes the address of the next instruction to execute and jumps to the function. That function then can access the arguments and put it’s return value in EAX and jump back to the pushed instruction address. The caller must then clear the stack and use the EAX return value.

However, a way to optimize your code with gcc is the -mregparm=N command, which will put the N < 4 first arguments in registers EAX, EDX, and ECX respectively and push the rest onto the stack. This is much quicker since it requires less memory access. However, you must make sure to compile all your code this way, otherwise you’ll have some strange interactions when the conventions are mixed.

Peace and chow,

Ranok

Why Better is Not Always Best

There has been a long debate on Windows versus Linux, Mac versus Windows, Apples versus Oranges, etc… I’m going to add my two cents to the fray, but in a way that looks at how each OS plays its role.

Windows: This is the dominant OS, it may not follow industry standards, but regardless is the norm. It has a horrid reputation for security as it is still trying to support legacy applications. It is also buggy, and a pain to develop on, however, the .NET framework is a step in the right direction. Windows made a rise when it was able to make computing both affordable, and simple, it wasn’t perfect, but it was good enough for its users.

Mac: Apple started out lost, using the shotgun approach to selling computers, many different models with very slight differences. However, once Steve Jobs trimmed down the breadth of choices and OS X came out, they had finally hit the sweet spot, selling powerful, easy to use software on high quality hardware. They are in the best position to take the lead, if they can lower their price points, as they will never be able to compete with a $200 computer from Dell. I’d suggest they release some very low end netbooks and cheap desktops to gain market share in both the education sector and as a computer for the ‘basic user’, those who only checks their email and surfs the web.

Linux: An oddball to say the least, it has been mostly community developed since its inception. Very popular with servers and more computer literate users, it still has very little market share. While there may be evidence to support it being the ‘best’ operating system, best is inherently subjective, Linux is made by technically savvy users for themselves, it is just now being looked at from a average user standpoint. While I prefer Linux, I also would consider myself a pretty technically skilled user, therefore enjoy the challenges of getting my system running perfectly, and the customizations it exposes. Linux has a long way to go before it will be considered viable for the average user, as most of the development is to make it better for the current userbase, not the one that doesn’t use it.

Well, now that I’m sure I’ve angered a number of people (please comment, I do like reading responses), I will end this post having put in my two cents, but very eager to see how the next few years change the playing field.

Peace and chow,

Ranok

Unifying Logins with LDAP

Over the past few days I got OpenLDAP installed on a VM, and configured a few other VMs to use the server for authentication. The real struggle was to get sudo-ldap to play nicely and to automate the system for a simple, yet granular system for giving people access to certain machines. Currently, I have a few configuration files that list the users, their password hashes and which machines they can administer. A few homebrew scripts I threw together then parse through those files and make the changes. If a user needs to be giving sudo access to three machines, rather than logging into those three machines and making a user, and granting access on each, just modify two files and you’re done. If you’re looking for more information on how it’s done, check out the COSI wiki, which has lots of cool information about all sorts of things.

Peace and chow,

Ranok