Josef “Jeff” Sipek

April 13, 2010

mail_conf_suck

Filed under: programming open-source — JeffPC @ 18:52

I was just looking at the source for Postfix, when I came across this function:

/* mail_conf_read - read global configuration file */

void    mail_conf_read(void)
{
    mail_conf_suck();
    mail_params_init();
}

It turns out that mail_conf_suck reads in the config file, and then mail_params_init does all the dirty work of initializing the internal data structures based on the config.

Anyway, that's the random thought of the day. I found it marginally amusing.

Edit: the code in question is in src/global/mail_conf.c.

November 10, 2009

z/VOS - running x86 code on z

Filed under: programming programming/mainframes — JeffPC @ 02:42

Earlier this year, I heard of a company that tried to make a product out of dynamic binary translation of x86 code to z/Architecture. Recently, I decided to look at what they do.

The company is called Mantissa Corporation, and their binary translation product is called z/VOS.

Much like VMWARE, they cache the translated code, in z/VOS's case it's really a must otherwise I'd guess the cost of traslation would make the result unusable. I like how they used VNC (see the demo mentioned below) to give the virtual x86 box a display.

There is an official blog that has some interesting bits of information. For example, they hint at how they use multiple address spaces to give a the x86 code the illusion of virtual memory. I am not quite sure why they list Decimal Floating Point facility as a requirement. Unfortunately, it has been a few months since the last update.

Their website also happens to have a demo of a small x86 assembly operating system starting up and running under z/VOS. I find this fascinating.

September 24, 2009

PAPI - Getting at Hardware Performance Counters

Filed under: citi documentation programming — JeffPC @ 23:45

Recently, I wanted to figure out whether or not an application I was analyzing was memory bound or not. While on this quest, I was introduced to Performance Application Programming Interface (PAPI).

There is a rather good HOWTO that shows step-by-step instructions on getting it all running on Debian. The text below is more or less just a short version of that HOWTO, with my thoughts interspersed.

PAPI is a library that hooks into the hardware performance counters, and presents them in a uniform way. Installation is rather simple if you pay attention to the installation instructions.

  1. Get the kernel source
  2. Get the perfctr tarball
  3. Extract the sources, and run the update-kernel script. I really mean this, if you try to be clever and apply the patch by hand, you'll have a broken source tree. (The script runs patch to fixup some existing kernel files, and then it copies a whole bunch of other files into kernel tree.)
  4. Configure, build, install, and reboot into the new kernel
  5. You can modprobe perfctr and see spew in dmesg

That's it for perfctr. Now PAPI itself...

  1. Get & extract the source
  2. ./configure, make, make fulltest, make install-all

That's it for PAPI. The make fulltest will run the tests. Chances are that they will all either pass or all fail. If they fail, then something is wrong (probably with perfctr). If they pass, then you are all set.

There are some examples in the src/examples directory. Those should get you started with using PAPI. It takes about 100 lines of C to get an arbitrary counter going.

Some other time, I'll talk more about PAPI, and how I used it in my experiments.

September 13, 2009

Think!

Filed under: open-source programming programming/kernel rants sysadmin — JeffPC @ 22:02

Alright, it ain't rocket science. When you are trying to decide which filesystem to use, and you see a 7 year old article which talks about people having problems with the fs on Red Hat 7.x (running 2.4.18 kernels), are you going to assume that nothing changed? What if all the developers tell you that things changed? Are you still going to believe the slashdot article? Grrr... No one is forcing you to use this filesystem, so if you believe a 7-year old /. article, then go away and don't waste the developers' & others' time.

September 13, 2009

Haskell Kernel Modules

Filed under: citi programming programming/kernel — JeffPC @ 17:57

Insanity! Someone has made it possible to write kernel modules in Haskell. (FYI, Haskell is a functional language with very strong typing.) Currently, they support only x86, but I wouldn't be surprised if some other architectures got a port soonish.

August 31, 2009

Count, Compare, Skip

Filed under: programming — JeffPC @ 04:20

I just remembered a fun fact about the Apollo Guidance Computer (AGC).

A few years ago, I was tinkering with emulating one. It kind of worked, but that's not important.

The AGC was an accumulator architecture, with 15-bit words (the accumulator (A) and few other "registers" were 16 bits), and 1's complement arithmetic.

Now, the fun fact. There was an instruction called 'CCS'. It took an address, loaded the accumulator with the value at the address, and then performed a 4-way branch. The easiest way to explain it is with a some code that demonstrates what happened with some C-style pseudocode (A = accumulator, Z = program counter):

Z = Z + 1;
A = mem[operand];

switch(A) {
        case POSITIVE:
        	A = A - 1;
        	/* Z is already incremented */
        	break;
        case POS_ZERO:
        	/* A is already a zero */
        	Z = Z + 1;
        	break;
        case NEGATIVE:
        	A = (~A) - 1;
        	Z = Z + 2;
        	break;
        case NEG_ZERO:
        	/* A is already a zero */
        	Z = Z + 3;
        	break;
}

So, in a program, you could see something like:

CCS addr1
TC  addr2
TC  addr3
TC  addr4
TC  addr5

So, data from addr1 was loaded, and then one of the TC instructions (TC = Transfer Control = a branch instruction) was jumped to depending on the value, then when the TC got executed, it unconditionally branched to some other address.

Of course, you didn't have to use TC, you could use any valid instruction and CCS would happily jump to it.

My understanding is that sometimes when CCS was used, some of the 4 possible targets were impossible. Not to waste memory, a committee was organized to keep track of these holes, and fill them in with useful constants.

July 11, 2009

Sharing the Computer's Time

Filed under: programming humor — JeffPC @ 06:09

Earlier today, someone I know sent me this Time article. I started reading the article, but something seemed a bit odd. To not spoil it for you, here's the text of the article:

The computer has become a main stay of big business in the U.S., but most small and medium-sized companies still find it too expensive for normal use. Last week two of the biggest computer makers, General Electric and Control Data Corp., introduced new systems that will offer the small business man the same computer advantages as the biggest corporation. Their move to what is called "time sharing" is part of a growing trend to market the computer's abilities much as a utility sells light or gas.

Dial for the Answer. Business some time ago began using computer centers to process data cards, count receipts or keep track of airline reservations from distant offices. Time sharing goes much beyond that. It links up as many as 500 widely separated customers with one large computer, lets each feed its own problems to the machine by telephone through a simple typewriter console. The time-sharing computer can answer questions in microseconds, is able to shift back and forth swiftly among the diverse programming needs of many companies, small and large.

Although still in its infancy, time sharing is already being used by business, government and universities. Boston's Raytheon Co. prepares contract proposals, and Arthur D. Little solves problems in applied mechanics through a time-sharing system run by Cambridge's Bolt Beranek & Newman. An other time-sharing firm, Keydata, will soon take up the problems of Boston distributors of liquor, books, automobile parts and building materials. Control Data, which introduced two time-shared computers last week, will open the U.S.'s biggest sharing center in Los Angeles next year. General Electric already has 88 customers, last week added a New York center to its service centers in Phoenix and Valley Forge, Pa.

From New York, IBM gives shared-time services to 50 customers, including Union Carbide and the Bank of California. Under G.E.'s system, a company can rent the big G.E. 265 for 25 shared hours a month for only $350, compared with a normal monthly rent of $13,000 for individual computers.

Plugging Them In. Some companies have discovered that time sharing has reduced to one-fiftieth the time needed to answer a problem, have found access to a large computer more profitable than ownership of a small or medium-sized machine. The Massachusetts Institute of Technology, one of the pioneers in time sharing, now has 400 users for its IBM 7094 computer, has served scientists as far away as Norway and Argentina. Experts predict that by 1970 time sharing will account for at least half of an estimated $5 billion computer business, will be used as widely and easily as the telephone switchboard.

Yep, that's right, this article is dated: Friday, Nov. 12, 1965. :)

July 10, 2009

Virtual Machines

Filed under: programming humor — JeffPC @ 19:55

Mendel Rosenblum, a Stanford University associate professor, VMWare co-founder, became an ACM Fellow, in 2008. The page about his fellow citation reads:

For contributions to reinventing virtual machines.

Very amusing.

July 10, 2009

Ch

Filed under: programming — JeffPC @ 19:49

This looks interesting, I should try to find some time to check it out.

July 8, 2009

chdir

Filed under: humor programming — JeffPC @ 16:51

This is probably as old as the internet itself...

Newsgroups: comp.unix.questions
Subject: NEED HELP FAST !!!!!!!!!
From: cs245@cs.somewhere.edu (The Unknown Hacker)
Date: 7 Apr 92 12:55:45 EDT
Organization: UNIX Guru's R Us!


HI, EVERYBODY!!!!
Sorry if this is a FAQ, but I've heard that a FAQ is something
everybody already knows, but since I don't know the answer to this
everybody doesn't know it, so it can't be a FAQ, so here I go ...

I've just created about the most Awesome change directory program ever
written.  If it doesn't find the target directory through an
exhaustive CDPATH search, it uses the most sophisticated spelling
corrector (based on a thorough analysis of Webster's on-line
dictionary, and a list of the 1000 most common directory names on Unix
systems throughout the world) to try to find a match that way.  If
that fails, then it tries to create the directory, and if that fails,
it opens /dev/uri-geller, and reads the mind of the invoker to try to
figure out what to do.  It executes with almost 0 impact on system
resources, and is most truly the finest/tightest code ever to grace
the memory of a computer.

The only problem is that it doesn't work.  No matter how I've tried,
once I've done that last chdir (and I've tried doing several identical
chdir(2)'s in a row to see if that would make the directory change
more "sticky" but that didn't work) I always end up where I started in
the shell I started my program in.  I've tried setting the PWD, and
CWD variables with putenv(3), but that doesn't seem to have any effect.

What it really seems to me, is I need some way of telling the shell what
directory it's supposed to be in when my program is done executing.
Put more simply, I need a way of modifying the environment of a parent
process.

E-mail responses only.  There's too much noise on this bboard for me to
be able to read it.  And HURRY!!!  I need to turn this project in by 5pm
tonight !!!!

 +----------------------------------------------------------------------------+
 |         _   /|                                                             |
 |         \'o.O'           UNIX Guru in training                             |
 |         =(___)=                                                            |
 |            U             Joe Programmer                                    |
 |     ACK.. THPPT!!!!      cs245@cs.somewhere.edu                            |
 |                                                                            |
 +----------------------------------------------------------------------------+

Powered by a pile of c