Monday, December 27, 2010

What about Chuck?


The BSD Logo.

One another occasion a very christian individual was noticing the devil logo, I tried to explain it was a daemon, not demon or devil and didn't have any satanic meaning, again they freaked.

You have to admit, that's sort of a Satanic symbol if you ever saw one, right?


From: FreeBSD.com
"Many people equate the word ``daemon'' with the word ``demon,'' implying some kind of Satanic connection between UNIX and the underworld. This is an egregious misunderstanding. ``Daemon'' is actually a much older form of ``demon''; daemons have no particular bias towards good or evil, but rather serve to help define a person's character or personality. The ancient Greeks' concept of a ``personal daemon'' was similar to the modern concept of a ``guardian angel'' --- ``eudaemonia'' is the state of being helped or protected by a kindly spirit. As a rule, UNIX systems seem to be infested with both daemons and demons." (p403) The earliest (and most popular) renditions of the BSD Daemon were created by John Lasseter.

That cute little red guy with the pitch fork is named Chuck


First Drawing with the Daemon Logo

Dictionary.com defines Daemon as A program or process that sits idly in the background until it is invoked to perform its task.

Historicaly though I always though of Chuck as more of a Gremlin really very much like the one portrayed in a Bugs Bunny cartoon "Falling Hare (1943)" before it was restored.



Officially Gremlins started in the 1920 at a RAF term for a low-ranking man saddled with oppressive assignments.

Gus the Airplane Military Insignia
Although this terms really take on color in World War II as a "an imaginary gnomelike creature who causes difficulties in aircraft."

Military Airplane Insignias

Also the Irish Gaelic word gruaimin, "ill-humored little fellow."

Drawing from Roald Dahl's book, "The Gremlins" Front Cover


This very much conjures up visions of these little gremlins running about secretly doing things.


From Roald Dahl's book, "The Gremlins"
"I've just found a nest of widgets," he said, and looked around in triumph. "Widgets?" said Stuffy. "Widgets? Never heard of them!"
But Jamface went on. "As I said, I've just found a nest of widgets located in the rear turret of my plane. There were twelve of them . very young ones."
"What are widgets?" asked Gus.
"It's very simple," said Jamface. "Widgets are the young of gremlins and fifinellas. No one knows until they grow up whether they are going to turn into males or females, but it's usually males; in each nest of twelve widgets only one will eventually turn into a fifinella."

The Church of BSD: Background

We are not a Satanic Cult Although we may be a cult, this has yet to be determined


One day I was at a restaurant explaining process control to one of my disciples.
I was mentioning how we have to kill the children (child processes) if they become unresponsive. Or we can even set an alarm for the children to kill themselves. That the parent need to wait (wait3) and acknowledge that the child has died or else it will become a zombie. The look of horror the woman sitting across had was unforgettable. I tried to explain it was a computer software thing but it was too late, she fled terrified, probably to call the police or something. I didn't really want to stick around too long to find out.
From: man ps Z Marks a dead process (a ``zombie'').

Hey, you just can't make up shit like this.

Don't forget that you have to Fork to Spawn Children, and the only way to Kill

On another occasion while being filmed doing a live video streaming event with Arthur C. Clarke, The camera filmed me key flying across the keyboard typing "kill 666". Just sort of odd the process ID, I didn't think much of it till It ended up in the final cut of a documentary video made about it.

And what about "chmod 666".

They say when you play a Microsoft CD backwards you can hear satanic messages...but that's nothing, if you play it forward it will install Windows! 
 
And what about Chuck?


 One another occasion a very christian individual was noticing the devil logo, I tried to explain it was a daemon, not demon or devil and didn't have any satanic meaning, again they freaked.

You have to admit, that's sort of a Satanic symbol if you ever saw one, right?

Read more at "What about Chuck".

BSD Unix History

Unix Started in AT&T Bell Labs in 1969. At time time is was freely shared as "scrap" The Berkely BSD 4.2 1983 OS was the first OS to support TCP/IP.
The Unix wars were the struggles between vendors of the Unix computer operating system in the late 1980s and early 1990s to set the standard for Unix henceforth. These battles are commonly held to have harmed the market acceptance of Unix and created a market gap that allowed the rise of Windows NT.

In the mid-1980s, the two common versions of Unix were BSD, from the University of California at Berkeley BSD4.2 released in 1983 , and System V, from AT&T. Both were derived from the earlier Version 7 Unix, but had diverged considerably. (This conflict was also known as the "UNIX wars" to some degree.) Further, each vendor's version of Unix was different to a greater or lesser degree.


A group of vendors formed the X/Open standards group in 1984, with the aim of forming compatible open systems. They chose to base their system on Unix.


X/Open caught AT&T's attention. To increase the uniformity of Unix, AT&T and leading BSD Unix vendor Sun Microsystems started work in 1987 on a unified system. This was eventually released as System V Release 4 (SVR4).

While this decision was applauded by customers and the trade press, other Unix licensees feared Sun would be unduly advantaged. They formed the Open Software Foundation (OSF), who released OSF/1, more closely based on BSD. AT&T and another group of licensees then formed UNIX International.

Technical issues soon took a back seat to vicious and public commercial competition between the two competing "open" versions of Unix, with X/Open holding the middle ground.

Linux kernel based on rewrite of Minux was released to the Internet in September 1991,

The first open source Unix port began in 1989 with 386BSD and first, incomplete traces of the port can be found in 4.3BSD NET/2 of 1991. It was first released in March 1992 (version 0.0) and in a much more usable version on July 14, 1992 (version 0.1).

Due to a lawsuit by AT&T, USL v. BSDi, some potentially so-called encumbered sources which existed within 386BSD were to be removed from all the derived systems, and the distribution of 386BSD was to be stopped. In late 1993


In 1993, AT&T sold Unix to Novell, who assigned trademark rights to X/Open. In 1996, X/Open and the OSF merged to form the Open Group, whose Single UNIX Specification is now the single standard for proprietary Unix. However, the damage to Unix's market share had been done.




BSD Unix

The BSD varients (FreeBSD, NetBSD, OpenBSD, etc) are UNIX based operating systems
that work on Intel PC based systems that have a reputation for being highly optimised,
highly secure and excellent (when decently configured) for keeping hackers at bay.


Linux does not compare all that well to BSD: having a reputation of being
a hacker's paradise to break into compared to BSD (FreeBSD at least).
FreeBSD (and the other BSD's) run some of the most intensely hit servers
on the globe, including ftp://ftp.cdrom.com. It can be said that the nicest
thing you can do for a hacker is replace Windows with Linux as not only is it
potentially easier to hack (one of the benefits of open source), but the system
becomes worth hacking into. The same cannot necessarily be said with BSD based UNIX's
which are built of sterner stuff to keep hackers at bay.


Thus the BSD based operating systems of which FreeBSD is one - have a reputation of being
better designed (by gurus no less!), more secure (and more security
conscious) and more robust than most other operating systems (including
Linux - an operating system - it is claimed - "written by kiddies - for kiddies").
Refer to:
FreeBSD, OpenBSD and SuSE 6.2 Eval Review by Keith Rankin
: "The differences between
FreeBSD and Linux used to be much more obvious than they are now.
Now it comes down to theology. The BSD world is still the 'high church' or Druid Unix. Blood will
be spilled on a stone altar at midnite when star systems are in
a certain alignment to learn the ways of this tribe. Linux is a
happier world. The spirits of Captain Kirk, Peter Pan and good beer come to mind."


("Buckets of Blood" and non-alcoholic prudery is official CCP14 computer operating system policy)

Remove all but the newest packages on hosts

Remove all but the newest packages on hosts

for h in $(ls XXX* | sed 's/\(\w*\)\..*/\1/' | sort -u ); do
ls -t $h*  | tail -n +4 
done | xargs sudo rm
 
list just packages. 
sed 's/\(\w*\)\..*/\1/'  

this turns "XXXyyy-1.23.rpm" in to XXXyyy-1
sort -u 

then only give me unique package names.
for h

indexs through each type of package.

Then we pass each package type $h* in to a ls -t that sorts by time,
tail -n +4  

this removes the first 3 lines from what it list in the ls, just the 3 newest versions
xargs 

then takes this list of files from everything before and passes it as an argument to rm

After IPv4, How Will the Internet Function?

from Slashdot:

"36 countries in the world have over 100% per-capita usage of mobile phones, and this is driving a real crunch on IPv4 addresses as more and more of these devices are data-capable. The mobile network operators are acting fast to deploy IPv6, and T-Mobile USA has had an IPv6-only trial going on for over 9 months now using NAT64 to bridge to IPv4 Internet content. It is interesting to note that the original plan for IPv6 transition, dual-stack, has failed since IPv4 addresses are effectively already exhausted for many people who want them. Dual-stack also causes many other issues and has forced the IETF to generate workarounds for end users called happy eyeballs (implying that eyeballs are not happy with dual-stack), and a big stink around DNS white-listing. How will you ensure that your network, users, and services continue to work in the address-fractured world of the future where some users have only IPv4 (AT&T ), some users have only IPv6 (mobile and machine-to-machine as well as developing countries), and other Internet nodes have both?"

Progress In Algorithms Beats Moore's Law

"Seen on the blog 'Algorithmic Game Theory,' a report to congress and the president about past and future advances in information technology notes that, while improvements in hardware accounted for an approximate 1,000 fold increase in calculation speed over a 15-year time-span, improvements in algorithms accounted for an over 43,000 fold increase."

Friday, December 24, 2010

Ubuntu blocking X11 solution

My servers are OpenSuSe and my personal machine is Ubuntu. On a local area network, I can run my X11 editor and edit files on the server. But remotely, like from home, it was not clear.

This did it. Add to /etc/ssh/ssh_config

ClearAllForwardings yes

I also explicitly set the ssh server

X11Forwarding yes

it is not clear if this is the default


Today (2010-12-29), I also noted in /etc/ssh/ssh_config

ForwardX11 yes

tc

Tuesday, December 21, 2010

The Mysteries of the Unix Date Command.

To do any math on dates is very difficult in any language. But in the Unix/Linux shell this can be a breeze.

This is done by converting all data time in to Seconds.

In Unix this is done by counting seconds from UTC or Universal Constant Time, 1/1/1970

So once you convert in to second, you can do math as usual, then convert time back to date time.


Example of how to convert back and forth

Conversion from Seconds UTC to string
-bash-3.2$ date --date "1970-01-01 1292970890 sec utc"
Tue Dec 21 14:34:50 PST 2010

Conversion from string to Seconds UTC
-bash-3.2$ date --date "12/21/2010 14:34:50 PST" "+%s"
1292970890
-bash-3.2$ date --date "Dec 21 14:34:50 PST 2010" "+%s"
1292970890

Current time
-bash-3.2$ date "+%s"
1292979451

Get Seconds UTC file creation date.
stat -c %Y filename
ls -l
-rw-r--r-- 1 jsokol jsokol       8 Sep 22 18:36 t
 
-bash-3.2$ stat -c %Y t
1285205797


So for doing math on time:


Get file age

(In Bash)
Returns how many hours old
expr \( `date +%s` - `stat -c %Z $filename` \) / 3600

Return age of oldest file in directory
expr \( `date +%s` - `stat -c %Y \`ls -t | tail -1\` ` \) / 3600

Create Shell alias of this
alias oldest='expr \( `date +%s` - `stat -c %Y \`ls -t | tail -1\` ` \) / 3600'

bash process ID PID

$$, My PID
$!, My Child PID
$PPID, My Parent PID

bash command line

#!/bin/bash
echo "$*"
echo "$@"
echo "$_"
echo "$#"

./test a b c
a b c
a b c
c
3

Friday, December 17, 2010

Ansi color codes in Ruby


#!/usr/bin/ruby
esc="\e["
st=""
x=30
 while x < 38 do
   y=40
   while y < 48 do
     st +=  esc+"#{x};#{y}m #{x};#{y} "
     y+=1
   end
   puts st+esc+"0m\a"
   st=""
   x += 1
 end
puts esc+"0m"



This output's



With a little work I am sure this can be made in to a simple function or library.
or just something you can send with a puts.

Ruby to MBox format.

I have over the past 20+ years written many scripts to deal with incoming mail.
I can process statistics from machine generated alert E-mails, rebroadcast E-mails and generate pages from them based on there content.


I was using a the IMAPClient library in Perl for this, but when my IMAP Mail server was migrate to an SSL based TLS/IMAP everything broke.

TLS encrypted port 993 RFC2595 RFC3501

After many long hours of struggling to get IMAPClient to work over SSL I just had to give up. It looks like something is just broken in that lib, I tried opening my own SSL socket then passing it to the lib, I tried having the lib itself connect to the SSL socket, no luck.

The Ruby net/imap just seems better written and it does work. Unfortunately it's lacking the message_to_file  function which I had to replace that functionality.



A small change in the scripts below could also simulate .forward also or support mail dir.
If you do that, please send me a copy  


In Perl for Non-secure IMAP
#!/usr/bin/perl

use Mail::IMAPClient;
my $imap = Mail::IMAPClient->new( Server       => 'mail.yourdomain:143',
                                   User         => 'jsokol',
                                   Password     => 'yea-right')
        or die "IMAP Failure: $@";

 foreach my $box qw( alarmpoint ) {
   my $file = "/uhome/jsokol/crapmail/". $box;
   $imap->select($box);

   my @msgs = $imap->search('ALL')
        or die "Couldn't get all messages\n";

   foreach my $msg (@msgs) {
     open my $pipe, "| formail >> $file"
       or die("Formail Open Pipe Error: $!");
     $imap->message_to_file($pipe, $msg);
     close $pipe
       or die("Formail Close Pipe Error: $!");
     $imap->delete_message($msg);
   }

   # Now expunge the messages and close the folder
   $imap->expunge($box);
   $imap->close($box);
 }

 $imap->logout();


I am just learning Ruby, so please excuse some of this code.

In Ruby secure TLS/IMAP
#!/usr/bin/ruby
require 'net/imap'

        server = "mail.yourdomain.com"
        port = 993
        ssl = true
        username = "jsokol"
        password = "yea-right"


        Net::IMAP.debug = false
        conn = Net::IMAP.new(server, port, ssl)
        resp = conn.login(username, password)

        conn.select('test')
        conn.search(['ALL']).each do |sequence|

                env = conn.fetch( sequence,"ENVELOPE")[0].attr['ENVELOPE']
                xdate =  env.date.split(" ");

               wkday = xdate[0].sub(/,/,"")
               day = xdate[1]
               month = xdate[2]
               year = xdate[3]
               time = xdate[4]


               if (day.length < 2)
                   day = "0" + day
               end

                box  = env.from[0].mailbox  + "@" +  env.from[0].host + "  " + wkday + " " + month + " " + day + " " + time + " " + year

                fetch_result = conn.fetch( sequence,  "RFC822")[0].attr['RFC822']
                if fetch_result
                     File.open( "MAILOUT" , "a") {|file|  file.write ("From #{box}\n#{fetch_result}\n\n\n") }
                end

                conn.store(sequence , "+FLAGS", [:Deleted]) # remove this line if you don't want to deltete these E-mails.
        end
        conn.expunge # remove this line if you don't want to deltete these E-mails.
        conn.logout
        conn.disconnect

Google Public DNS

Few people are aware of this but Google offers a DNS service.

This is particularly useful in a number of situations.

*If you are inside a corporate firewall and want to test host DNS entries appear to the outside world.

*If you don't trust your local ISP, or their DNS is having issues.

I often run scripts to check massive blocks of IP's


#while read ADDR
for ADDR in $IPLIST; do
 DNSR=`host $ADDR 8.8.8.8 | tail -1 | awk ' {print $NF}' | sed 's/3(NXDOMAIN)/NONE/'

echo  "$HOST : $ADDR $DNSR" >> ADDR-LIST.txt

done

Google Public DNS IP addresses

The Google Public DNS IP addresses are as follows:
8.8.8.8
8.8.4.4

Using Google Public DNS

8.8.8.8, A DNS Number for Faster Browsing

Thursday, December 16, 2010

Lua Programming

Lua is a sexy little language out of Brazil.


http://wiki.eluaproject.net/Overview

http://wiki.eluaproject.net/

Ruby programming

Been learning Ruby lately. Didn't think I'd like it better then Perl But I do.

I will post some links I have found useful on this page.

Ruby Basic Tutorial

Ruby in Twenty Minutes

Ruby in 100 Minutes

Ruby 101: Substrings in Ruby

Some files space is just wasted

Recently, while testing some software that did directory tree displays, I noted 1,505,297 bytes used just to store the names for the /usr directory for Linux. Or 28000+ subdirectories.

Again, that is 1,505,297 bytes just for the directory names.

tc

Saturday, October 02, 2010

Oil and Lube

One would think that computers are not in need of regular maintenance, in fact they are. After some time in operations - months or years, any original lubricants are gone. Recently, SVBUG was gifted several servers that had seen their prime, but were still useful. A little Oil and Lube did the trick.

Here are a couple of Tutorials on :

How to Remove and Apply Thermal Compound By Jeremy Blum (aka sciguy14)
http://www.youtube.com/watch?v=I3gx6c62D7I

Quiet noisy computer fans with a drop of oil by Greg Shultz
http://articles.techrepublic.com.com/5100-10878_11-5034842.html

tc

Tuesday, September 28, 2010

BSD Event Feed and RSSFeed

Looks like a semi-official BSD Events list,

http://twitter.com/bsdevents

The RSS Feed is on the right below the menu junk. It's also below:

http://twitter.com/statuses/user_timeline/23451058.rss

tc

Tuesday, August 31, 2010

Super Computer taking over?

In a recent story (May, 2010), SEC Chairman Admits: We’re Outgunned By Market Supercomputers, a luddite might find reason to fear big brother. But in fact a mystery remains from the so-called "Fat Finger Incident" on May 6, 2010. The incident, such that it was, trigger "a total drop of 9.16 percent from the previous day’s close".

I'm sure conspiracy theories will abound as to the reason for this - including the demise of certain individuals. More to the point of this article, it cannot be sufficiently underestimated the problems the stock market has created.

It has been reported that because modern stock trading is essential completely electronic --- that dealers look to have their computers as close to the trading computers as possible. The idea is to be able to process orders microseconds quicker than the competition.

In fact it has also been reported that traders are "snipping" as the market moves. That is, "snipping" makes a few cents, if not hundreds of a cent as the market (or a particular stock) moves in a direction. It has even been suggested that dealers are making these "few cents" on their own client's "trades". It has even been suggested that these dealers, having prior knowledge of the limits of their clients, are pushing the pricing to the limit.

This last scenario, as suggested, means the buyer is actually paying more than they would have had the closing price not been known to the dealer.

If this is true, then it appears the dealers are undermining the confidence of their own business.

tc

Thursday, August 26, 2010

Notes on Cloud Computing

From a recent BayLisa meeting, in which the speaker failed to arrive, the topic of the night was "Cloud Computing". The first order of business was to define its meanings.

The moderator started by asking if anyone had direct experience in this or similar. I started by stating I had worked in a video-over-the-internet business in the late 90s. Then stated that "cloud computing" was marketing hype.

To make this short, this is the best definition I could write down:
Cloud Computing
Either a high-speed on-demand distributed or a high-speed on-demand clustered computing with invisible redundancy. The best uses to date appear to be optical recognition, and audio recognition. In addition, there are working businesses very reminiscent of "Thin Computing".

Friday, July 30, 2010

Happy sysadmin day everyone!

http://sysadminday.com/

>  What about the DBAs? They need something too:

http://www.dbaday.com/

ORA-24123 feature "dbaday" is not yet implemented

24123, 00000, "feature %s is not yet implemented"
// *Cause: An attempt was made to use the specified feature, but the feature is
// not yet implemented.
// *Action: Do not attempt to use the feature.
// 

Saturday, July 17, 2010

Apps, Apps, How many apps?

While browsing the NetBSD website I found this nice chart.

tc

Thursday, July 08, 2010

scp recursive copy

If you've set up a copy using:

scp -r tc@cup:~/myremotestuff/* .

You may have gotten the error

scp: No match

What is not obvious is "what the error is". What has happend is scp tries to match to a local name when infact the intent is to match a remote name. Remove the wildcard (*) and all will be good.

tc

Wednesday, March 10, 2010

How to write more reliable servers. - dealing with failures

Given enough time most Internet servers will crash. It could be a memory leak, or some unexpected behavior from a new browser, or a deliberate denial of service attack. It could even be from hardware problems such a flaky memory chips.

The question is how do you deal with this.

If you take your basic C/C++ TCP/IP server application, when it dies it dies.
Many people set up some mechanism to monitor it and page a technician to restart it. This has many drawbacks and can lead to periods of prolonged downtime if alerts are missed or crashes become frequent.

Web servers only became reliable when NCSA 1.4.1 came it. It was very well thought out and well written and most web service since have copied the mechanisms it used. NCSA used a parent process that spawn child processes to actually do the work. When a child process dies, the parent wakes up and immediately restarts them.

In my former company IBS(Internet Broadcast Systems) and later at DVBS (Digital Video Broadcast systems) we called this a keep_alive.


The simplest example can be a shells script.
while true
do
server
echo "server crashed" > log
sleep 1
done


With in C server code

int main(int argc, char *argv[])
{

    printf("Started...\n");

...

  Refork:
    switch (pid = fork()) {
    case -1:
 printf("\nCan't fork!\n");
 FatalError(3);
    case 0:
 break;
    default:
 wait(0);
 printf("\nChild died!\n");
 goto Refork;
    }

    printf("Forked...\n");

Friday, January 15, 2010

Linux Disable PC Speaker beeps

Runtime change

  • Check if you have the pcspkr module loaded.
#lsmod | grep pcspkr
pcspkr                  7105  0
  • Remove the module. lsmod will return nothing if the module was removed.
#rmmod pcspkr
#lsmod | grep pcspkr
  • Restore the module when done.
#modprobe pcspkr
#lsmod | grep pcspkr
pcspkr                  7105  0

Permanent change

  • Add the pcspkr module to the modprobe blacklist file.
# vi /etc/modprobe.d/blacklist
{Add the lines below to the file.}
# pcspkr - turn off pc speaker "BEEP!"
blacklist pcspkr
  • Reboot, and check if the pcspkr module was loaded. If the blacklist file kicked in then nothing will be returned.

Tuesday, January 12, 2010

Google Chrome

It's using many of the concepts I expored in my talk about the Amorphous OS, I will have put those slides back on the internet.

A big part is no local files.

http://googleblog.blogspot.com/2009/11/releasing-chromium-os-open-source.html

http://www.chromium.org/chromium-os/chromiumos-design-docs

http://en.wikipedia.org/wiki/Google_Chrome_OS

Looks like it's build on a stock Linux Kernel.. I was thinking about this and they need to get ride of the paradigm of a process and replace it. 
Processes have there own time slices and memory.  They seems to have spend a lot of effort to give each browser tab it's own process, and in some circumstances they could not.

What they need to do it get rid of the whole concept and go with an object based memory model.

Where some objects are shared between processes where processes are not sandboxed memory as much as just time slices and sandboxed memory objects associated with parent objects.

Thursday, December 31, 2009

An Inside Look At Warhammer Online's Server Setup

From Slashdot: http://games.slashdot.org/story/09/12/31/0428200/An-Inside-Look-At-Warhammer-Onlines-Server-Setup

An article at Gamasutra provides some details on the hardware Mythic uses to power Warhammer Online, courtesy of Chief Technical Officer Matt Shaw and Online Technical Director Andrew Mann. Quoting: "At any given time, approximately 2,000 servers are in operation, supporting the gameplay in WAR. Matt Shaw commented, 'What we call a server to the user, that main server is actually a cluster of a number of machines. Our Server Farm in Virginia, for example,' Mann said, 'has about 60 Dell Blade chassis running Warhammer Online — each hosting up to 16 servers. All in all, we have about 700 servers in operation at this location.' ... 'We use blade architecture heavily for Warhammer Online,' Mann noted. 'Almost every server that we deploy is a blade system. We don't use virtualization; our software is somewhat virtualized itself. We've always had the technology to run our game world across several pieces of hardware. It's application-layer clustering at a process level. Virtualization wouldn't gain us much because we already run very close to peak CPU usage on these systems.' ... The normalized server configuration — in use across all of the Mythic-managed facilities — features dual Quad-Core Intel Xeon processors running at 3 GHz with 8 GB of RAM."

Why Coder Pay Isn't Proportional To Productivity

From Slashdot: http://developers.slashdot.org/story/09/12/23/1820214/Why-Coder-Pay-Isnt-Proportional-To-Productivity

Why Coder Pay Isn't Proportional To Productivity
"John D. Cook takes a stab at explaining why programmers are not paid in proportion to their productivity. The basic problem, Cook explains, is that extreme programmer productivity may not be obvious. A salesman who sells 10x as much as his peers will be noticed, and compensated accordingly. And if a bricklayer were 10x more productive than his peers, this would be obvious too (it doesn't happen). But the best programmers do not write 10x as many lines of code; nor do they work 10x as many hours. Programmers are most effective when they avoid writing code. An über-programmer, Cook explains, is likely to be someone who stares quietly into space and then says 'Hmm. I think I've seen something like this before.'"

Wednesday, December 23, 2009

An Open Source Compiler From CUDA To X86-Multicore

From Slashdot:

An Open Source Compiler From CUDA To X86-Multicore


"An open source project, Ocelot, has recently released a just-in-time compiler for CUDA, allowing the same programs to be run on NVIDIA GPUs or x86 CPUs and providing an alternative to OpenCL. A description of the compiler was recently posted on the NVIDIA forums. The compiler works by translating GPU instructions to LLVM and then generating native code for any LLVM target. It has been validated against over 100 CUDA applications. All of the code is available under the New BSD license."

Monday, December 21, 2009

X11 Server Setting No Mouse, Try AllowEmptyInput

Upon setting up FreeBSD 7.2 from 6.4, I though that unrolling the tarball would do it. I did copy xorg.conf to /etc/X11, but no luck. I then read the error log (/var/log/Xorg.0.log). After a search on wiki.x.org, I did see a reference on to how to TURN OFF all keyboard and mouse input by adding to the Section "ServeFlags"

Option "AllowEmptyInput" "True"

I reversed it to

Option "AllowEmptyInput" "False"



tc

Tuesday, December 15, 2009

Fork Bomb

The bash fork() bomb
:(){ :|:& };:
This is a bash function. It gets called recursively (recursive function). This is most horrible code for any Unix / Linux box. It is often used by sys admin to test user processes limitations (Linux process limits can be configured via /etc/security/limits.conf and PAM).

Once a successful fork bomb has been activated in a system it may not be possible to resume normal operation without rebooting, as the only solution to a fork bomb is to destroy all instances of it.

Understanding :(){ :|:& };: fork() bomb code

:() - It is a function name. It accepts no arguments at all. Generally, bash function is defined as follows:

foo(){
arg1=$1
echo ''
#do_something on $arg argument
}

fork() bomb is defined as follows:

:(){
:|:&
};:

:|: - Next it call itself using programming technique called recursion and pipes the output to another call of the function ':'. The worst part is function get called two times to bomb your system.

& - Puts the function call in the background so child cannot die at all and start eating system resources.

; - Terminate the function definition

: - Call (run) the function aka set the fork() bomb.

Sunday, December 13, 2009

OpenDarwin has Shut Down!

When did this happen?   I am finally getting around to developing a mac app. I wanted to use SDL and they had a great ports collection apparently http://darwinports.opendarwin.org/ that is now GONE! Shit.

http://docs.huihoo.com/darwin/opendarwin/news/shutdown.html

OpenDarwin Shutting Down
2006.07.25
OpenDarwin was originally created with the goal of providing a development environment for building and developing Mac OS X sources as well as developing a standalone Darwin OS derivative. OpenDarwin was meant to be a development community and a proving ground for fixes and features for Mac OS X and Darwin, which could be picked up by Apple for inclusion in the canonical sources. OpenDarwin has failed to achieve its goals in 4 years of operation, and moves further from achieving these goals as time goes on. For this reason, OpenDarwin will be shutting down.
Over the past few years, OpenDarwin has become a mere hosting facility for Mac OS X related projects. The original notions of developing the Mac OS X and Darwin sources has not panned out. Availability of sources, interaction with Apple representatives, difficulty building and tracking sources, and a lack of interest from the community have all contributed to this. Administering a system to host other people's projects is not what the remaining OpenDarwin contributors had signed up for and have been doing this thankless task far longer than they expected. It is time for OpenDarwin to go dark.
Project admins for all active projects have been notified, and we will be working with them to provide as seamless a transition to their new homes as possible. We don't want to boot anyone off, we will be operating the machines as usual for several months, until everyone has had a chance to move elsewhere.
We will continue to provide email and dns redirection after the machines go dark. We'll be looking at what other redirection services are needed and can be provided after hosting has ceased.
The OpenDarwin team would like to thank everyone who did contribute to the project, and our apologies to active, loyal projects that have to move.
Thanks,
- OpenDarwin Core Team and Administrators

Thursday, November 19, 2009

Method for "The INSECURE X11" connection

If you have already setup an ssh connection to your remote machine, then getting the X11 client application (on the remote) to show up on your (local) diplay is easy.

CAVEAT: THIS IS THE INSECURE METHOD THE SSH PEOPLE ARE ALWAYS WARNING ABOUT.

Before you login to the remote machine make sure your X11 server (Note: the server runs the display, not the programs, clients, or applications.), make sure it is listening for TCP connections. MANY X11 display managers have this turn OFF by default, John has shown how to do this in his article for gdm (gnome)

I use icewm, so I just use startx(1). As such, the following is at the end of my .login file.

echo Starting X in 3 seconds
sleep 3
startx -listen_tcp

Next, login to the remote machine and at the commandline enter:

$ export DISPLAY=192.168.123.100:0.0

then test your connection with

$ xterm


Then rather than hardcode the display add the following to your .chsrc or .bashrc file:

if [ -n "$SSH_CLIENT" ]
then
X=`echo $SSH_CLIENT | cut -f 1 -d " "`
# The insecure way
#export DISPLAY=$X:0.0
# The secure way
if [ "$X" = "192.168.123.100" ]
then
export DISPLAY=127.0.0.1:1
fi
#echo X $X
fi


NOTE #1: Substitute your domainname or your IP for 192.168.123.100.

NOTE #2: Your SSH shell/terminal will not close, if you have an X application running the secure way.

NOTE #3: This method is extremely useful, if you have control of your firewall.

Wednesday, November 18, 2009

Tech World Anagrams

Tech World Anagrams

Some are better then others.

Medical Marijuana = AN IDLE JAMAICA RUM

Thomas Edison = ATOMS DO SHINE
Albert Einstein = TEN ELITE BRAINS

Microsoft = IS COMFORT
Microsoft Windows = I'D WOW CONFORMISTS
Microsoft Windows Xp = WORM DOWNS PC, SO FIX IT
Microsoft Word = IFORMWORST.DOC
Microsoft Office = IS OF COMIC EFFORT
Microsoft Vista = FASCIST OR VOMIT
Microsoft Windows Vista = OVATIONS WORM SWIFT DISC
Microsoft Windows seven = NOW SNOW-COVERED MISFITS

Sun Microsystems = COSTS MESS - MY RUIN
Sunsoft = NOT FUSS

Freebsd Unix = BURNED FIXES
Netbsd unix = BID NEXT SUN
Openbsd Unix = INDEX UP SNOB
Berkeley System Distribution = TRUSTILY. BEE'S KNEES MORBIDITY
Berkeley Software Distribution = SWEATIEST OR BROKENLY BRUTIFIED
Gnu's Not Unix = UNSUNG TOXIN & SIX GUN ON NUT
Sourceforge = OGRE OF CURSE & FORCE ROGUES
Debian Linux = I ANNEX BUILD
Redhat Linux OS = Dear! Lush Toxin = IN HOARD EXULTS
Fedore Core OS = FREE CODE OR SO
Fedore Core Linux = IF DELUXE CROONER
Linus Torvalds = STUN AVID ROLLS

Public Domain = BULIMIAC POND

Free Open Source = UP OF SERENE CORE & OPENER OF SECURE

Free Open Source Software = SUFFOCATE OR SERENE POWER & NOW USE CAREFREE POOFTERS

Free Software Foundation = NOW OF SNUFFIER TOADEATER & WORN-OUT IF TONE-DEAF FEARS
-- TOADEATER [Originally, a charlatan's helper who ate (or pretended to eat) poisonous toads so that his employer could display his prowess in expelling the poison.]


Internet Guru = TURGENT URINE


World Wide Web = BORED, IDLE? - "W.W.W."
Web Surfing = IF SNUB GREW & WIN SERF BUG
Network Solutions = NOW STINK OUT LOSER
Internic = IN CRETIN
Internet protocol = COOL! NOT INTERPRET
Internet Protocol Version Six = INTROVERT CORNIEST EXPLOSION & SO INEXPERT SILVER CONTORTION
Domain Registry Service = REVENGES TRIM IDIOCRASY & I'M ANGRIEST RE-DISCOVERY

Boarder Gateway Protocol = COWPAT OR DEROGATORY ABLE

Secure Shell = HER CLUELESS

Universal Serial Bus = ILLUSIVE AS RARE SNUB

The C Programming Language = CLEAN RAMPAGING TOUGH GERM & GLEAM HOT GRUMPING CARNAGE

T One Line = NON-ELITE
Co Location = COOL ACTION!
Server Room = ERRORS MOVE
Beowulf Cluster = WE'LL BRUTE FOCUS

Relational Database = INALTERABLE AS A TOAD

High Definition Television = OH NO! THIEVING INFIDELITIES
Music Television = SIT, VOLUME IS NICE
Blue Ray Disk = IS BULKY DEAR

Silicon Valley = SOCIAL 'N' LIVELY & Villainy Close

American Telephone And Telegraph = REPELLANT MEATHEAD OR CHEAPENING & THE PAEDOPHILE, CLEAN ARRANGEMENT

Pacific Bell = IF CLIP CABLE

Computational Chemistry = PSYCHOTIC, MEAN MUTILATOR

high speed internet = EIGHTH SERPENTINED
This is really interesting in many mythologies. Gnostic, Hundu, Egyptian, Japaneses


Now to really blow your mind!
If your wondering how some of these anagrams ring true then think about these anagrams

Who Is Answering This? = A WRITHING SHOWINESS & WIN SINISTER HOGWASH

Messages In Anagrams = A MASSAGER MANGINESS
massage is to manipulate
manginess is defined as Mean; contemptible


Anagram Studies = Sugared Stamina & ARGUED SATANISM & Grade us, I'm Satan!

Friday, November 13, 2009

X Windows over ssh

Before we can get started you must enable your local X Server to recieve from the network.


To do this in Linux in edit /etc/X11/gdm/gdm.conf
Change:

#DisallowTCP=true
DisallowTCP=false


You will need to reboot your Linux box or restart the X-server which is more then I care to try to explain here. 

ssh -R 6001:127.0.0.1:6000 sokol@remote.host.name

sokol@192.168.1.116's password: xxxxx
Last login: Fri Apr 1 12:04:48 2005 from 192.168.1.108


[sokol@localhost ~]$ xterm -display 127.0.0.1:1


-- THEN an Xterm will pop-up on your local machine.


If you install cygwin on your windows PC this will also work using the X server in cygwin, or my favorate is using Hummingbird Exceed ( I have an ancient copy I use) on windows but over the ssh on Cygwin


Works great. I can run synaptic remotely and almost all X-apps that don't do high end graphics like games or video.

How to get a password-less Putty Session

==How to get a password less Putty Session==
Putty is the virtual ssh terminal under with windows.

Download putty-sshgen

Run putty-sshgen & generate keys

Go to the putty configuration for the session you want to be passwordless.

Add an entry for the ssh private key
     Session->Auth->

Login to your linux/bsd server

Add to ~/.ssh/authorized_keys the public key in the following fashion
  1. add a blank line
  2. add "ssh-rsa" with a blank space
  3. add the putty-sshgen public key, without the dashes, and all on one line.
When done ~/.ssh/authorized_keys should look like this:
       ssh-rsa 3NzaC1yc2EAAAAA--- RANDOM CRAP HERE ---aC1yc2EAA=

Tuesday, October 20, 2009

Fair Use Statement

I just want to take a moment here to point out something.

Fair Use Statement


This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. Such material is made available in an effort to advance understanding of issues of environmental and humanitarian significance. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those who have expressed a prior interest in receiving the included information for research and educational purposes.

Monday, October 19, 2009

My notes on TCP/IP stacks.

Please excuse, some if this is just stuff I grabed off of web sites for further investigation.

TCP/IP stacks


Mini TCP/IP stacks.

uIP   http://www.sics.se/~adam/uip/index.php/Main_Page

lwIP  http://savannah.nongnu.org/projects/lwip/    lwIP is significantly more complex

uC/IP http://sourceforge.net/projects/ucip/   uC/IP - TCP/IP for microcontrollers

Alpine - user space TCP/IP  (have source code somewhere)
UPDATE July 20, 2011:
I found my Alpine code, but it's only the Alpine4Linux. 

The file can be downloaded from : http://www.dnull.com/Alpine/
I'd like to put these up on source forge or at least something like box.net where the code can no longer get lost. 

Daytona ""   http://nms.lcs.mit.edu/~kandula/data/daytona.pdf

----------------


> i want to move tcp/ip stack(including routing and
> netfilter) to userspace, my goal is to trace all the
> instructions involved in a firewall and router since i
> don't know how to trace these instructions inside the
> kernel. i want to get something like:
>
> incoming ip packets(a file)-->fake ISR-->tcp/ip
> stack-->outgoing ip packets( to /dev/null).
>
> my question is: is it possible and relatively easy to
> move tcp/ip stack to user space?
This comes up fairly frequently, it might be a good addition to the FAQ.
Here's my attempt at an answer culled from prior messages.

Several people have user-mode network stacks at various levels of
development, but it is *highly* unlikely for them ever to get into
the kernel proper (see the monolithic versus microkernel debate at
http://www.kernel.org/pub/linux/docs/lkml/#s15-4).

Here are some URLs to which you can refer for more information:
        http://www.cl.cam.ac.uk/Research/SRG/netos/arsenic/
        http://www.cs.nwu.edu/~pdinda/minet/minet.html
        http://www.joerch.org/tcpip/
        http://freshmeat.net/projects/libutcp/

However, for security purposes, you probably do not want a user-mode stack.
You want an extensible packet handling mechanism, and can be found with:
        iptables/ipchains -- the native Linux firewalling tools,
                http://netfilter.samba.org/
        tc -- the Traffic control program,
                http://www.sparre.dk/pub/linux/tc/
        libpcap -- packet capture library,
                http://www.tcpdump.org
------------------------------
---------------------
I've started a syncookie fw using a daemon process  ???

I do this using the REDIRECT ( ipchains ) / QUEUE ( ipfilter ) targets,
to get the packets to userspace. Once there, you can do what you want
using libpcap or syuscalls.

-------------------------------------------------------

[10] C.A. Thekkath, T.D. Nguyen, E.Moy and E.D.
Lazowska, ‘Implementing Network Protocols at User
Level,’ in Proceedings SIGCOMM 1993,
San Francisco, pp. 64-73, September, 1993.

[13] C. Maeda and B.N. Bershad, ‘Protocol service
decomposition for high-performance networking,’ in
14th ACM Symposium on Operating Systems
Principles
, December 1993.

------------------------------------------------------
[15] G.L. Peterson, “Myths about the mutual exclusion
problem,’ in Information Processing Letters, Vol. 12,
No. 3, pp. 115-116, June 1981.
A Appendices
A.1 Peterson’s algorithm
Peterson’s algorithm for mutual exclusion between two
processes is as follows (also see [15]):
Lock()
{
wantAccess[ME]=TRUE;
nextAccess=YOU;
while (wantAccess[YOU] && nextAccess==YOU)
/* Add yield code here */
;
}
Release()
{
wantAccess[ME]=0;
}

A.2 Edwards’ Algorithm
This algorithm for mutual exclusion exploits the fact that
the child process runs at real-time priority and so cannot be
pre-empted by the user process:
Lock()
{
#ifdef CHILD_PROCESS
if (disable_child) {
/* If user process has disabled us
* then we block and wait for him to
* wake us up
*/
child_blocking=TRUE;
WaitOnSemaphoreForWakeup();
}
#else
/* We know child must be blocked at the
* moment (thus not holding lock) as it
* runs as a real-time priority so can
* not be pre-empted
*/
disable_child=TRUE;
#endif
}
Release()
{
#ifdef CHILD_PROCESS
if (wakeup_user_process) {
WakeupSleepingUserProcess();
}
#else
disable_child=FALSE;
if (child_blocking) {
child_blocking=FALSE;
SignalWaitSemaphore();
}
#endif
}

-------------------------------------------
http://www.vzavenue.net/~neelnatu/alpine4linux/alpine4linux.txt
 

UPDATE July 20, 2011:
I found my Alpine code, but it's only the Alpine4Linux. 

The file can be downloaded from : http://www.dnull.com/Alpine/


--------------------------------------------------


Date: Fri, 30 May 2003 11:53:23 -0700 (PDT)
To: freebsd-net@freebsd.org

natun@rpi.edu or neelnatu@yahoo.com

Neelkanth Natu (neelnatu@yahoo.com)

Hi all,

Alpine4Linux is a userlevel FreeBSD 4.8 networking stack running on top of a stock Linux kernel.  It is an implementation of an idea that I came across in a paper[1] by David Ely, Stefan Savage and David Wetherall.

Alpine4Linux consists of a userland server program that runs the FreeBSD kernel code as well as
the unmodified networking stack. Client programs use the Alpine stack by setting the LD_PRELOAD
environment variable to link to libraries, that intercept socket related system calls. These
intercepted system calls are routed to the Alpine server over a TCP connection established on the loopback interface.

Alpine4Linux goes great lengths to ensure that its behavior is identical to that of a FreeBSD
kernel as far as networking is concerned. Thus, in addition to the unmodified FreeBSD stack.
Alpine4Linux also has unmodified socket layer code, file descriptor code, tsleep and wakeup for
e.g. It also has a rich client-side library that supports almost all socket functions as well as
functions like fork() that are commonly used by server programs.

I have tested stock Linux programs like telnet, nmap, ifconfig, vsftpd-1.1.3 etc. against
the Alpine stack. I have only compiled it on a Redhat 8.x Linux box, so if someone manages to run it on another Linux distribution/kernel please let me know.

You can find more information at: http://www.vzavenue.net/~neelnatu/alpine4linux

Hopefully someone finds use for this.

thanks
Neel

[1] Alpine: A user-level infrastructure for network protocol development
    David Ely, Stefan Savage, David Wetherall
    http://alpine.cs.washington.edu/

----------------------------------------------------------


Application-L evel Protocol Infrastructure for Network Experimentation
alpine_debug.c
Alpine_FreeBSD3x-0.10.tar.gz.
http://web.archive.org/web/20050208075748/http://alpine.cs.washington.edu/distfiles/Alpine_FreeBSD3x-0.10.tar.gz

-----------------------

--------------
TCP_congestion_avoidance_algorithm

http://www.cs.arizona.edu/projects/protocols/
http://en.wikipedia.org/wiki/TCP_Vegas
http://en.wikipedia.org/wiki/TCP_congestion_avoidance_algorithm
 
TCP Tahoe and Reno
TCP Vegas
TCP New Reno
TCP Hybla   high-latency terrestrial or satellite radio link
TCP BIC     In linux 2.6.8 through 2.6.18
TCP CUBIC  In linux  since version 2.6.19
Compound TCP (CTCP) is a Microsoft algorithm that is part of the Windows Vista and Window Server 2008 TCP
YeAH TCP - Yet Another Highspeed TCP - Linux

2.6.22
TCP Illinois congestion control. This is an implementation of TCP Illinois invented by Shao Liu at University of Illinois. It is a another variant of Reno which adapts the alpha and beta parameters based on RTT. The basic idea is to increase window less rapidly as delay approaches the maximum. See the papers and talks to get a more complete description

YeAH-TCP congestion control algorithm implementation. YeAH-TCP is a sender-side high-speed enabled TCP congestion control algorithm, which uses a mixed loss/delay approach to compute the congestion window. It's design goals target high efficiency, internal, RTT and Reno fairness, resilience to link loss while keeping network elements load as low as possible. For further details look here: http://wil.cs.caltech.edu/pfldnet2007/paper/YeAH_TCP.pdf

TCP cubic update for 2.6.22. The new version improves on its scalability, fairness and stability. So in all properties, we confirmed it shows better performance


Fastsoft
http://www.fastsoft.com/downloads/FASTTCP-IEEENetwork-0501.pdf

-----------------------------------

http://www.sics.se/~adam/miniweb/

web-enabled embedded systems

Many devices (printers, etc.) now use not just standard Internet Protocol but have a small web server embedded in them for input and to indicate status rather than using floppy disks or LCD panels or tiny little keyboards or other proprietary communication protocols.
[FIXME: Is there a better file for me to keep this category ?]
web appliances
[ Intelligent Instrumentation, Inc. http://www.instrument.com/ethernet data acquisition system ] is very similar ...



---------------------------------------

Fixing the Unfairness of TCP Congestion Control

"George Ou, Technical Director of ZDNet, has an analysis today of an engineering proposal to address congestion issues on the internet. It's an interesting read, with sections such as "The politicization of an engineering problem" and "Dismantling the dogma of flow rate fairness". Short and long term answers are suggested, along with some examples of what incentives it might take to get this to work. Whichever side of the neutrality debate you're on, this is worth consideration."

By 1999, the first P2P (peer-to-peer) application called Swarmcast began to blatantly exploit Jacobson’s TCP congestion control mechanism.  Using a technique called “parallel incremental downloading”, Swarmcast could grab a much larger share of the pie at the expense of others by exploiting the multi-stream and persistence loophole.  These two loopholes would be used by every P2P application since.







Mobile-ITX new super small PC motherboard form factor

This is a new standard PC motherboard form factor that is almost the same size as a cell phone.


http://www.linuxdevices.com/news/NS2010384636.html
 

Via CEO Wenchi Chen revealed a business card-sized motherboard billed as the "world's first industry-standard form-factor for PC/phone convergence," at Computex today. The "mobile-ITX" board measures 3 x 1.8 inches -- half the size of Via's "pico-ITX" form-factor -- and runs Linux or Windows XP Embedded.
 
Via's mobile-ITX board prototype
(Click to enlarge)


The mobile-ITX board that Chen demonstrated this morning appears to be based on a 1GHz "C7-S" processor -- apparently a standard Via
C7-M shoe-horned into a 9 x 11mm package. The chip had not previously been announced. The mobile-ITX board also apparently uses an "S" (small) version of the CX700 integrated north-/south-bridge chipset. And, it appears to have an on-board DC-DC converter. Additionally, according to Via, the board includes a CDMA baseband processor chip, suggesting that the mobile-ITX board could be used as the basis for x86-compatible smartphones.

Motorola phone compared to mobile-ITX

According to a brief item at EpiaCenter, Via's mobile-ITX board will be available with 256MB or 512MB of RAM soldered on-board, and will run Linux or Windows XP Embedded. Even an embedded version of Windows Vista may be too much for the little board, however, a Via spokesperson admits.

Chen stated, "This prototype Mobile-ITX gives a glimpse into the future of ultra mobile devices and the real convergence of computing and communications. Yet this is only the start. We see the platform shrinking still further, with ever richer blends of functionality, that will truly make ultra mobility the normal way of enjoying our content and our communications."


Marketing Manager Tim Brown with Via's NanoBook UMPC reference design, and CEO Chen with mobile-ITX prototype
(Click to enlarge)



Given that Chen positioned mobile-ITX as an "industry standard," lots of technical specifications about the form-factor should become available shortly. Meanwhile, EpiaCenter has posted a few photos, and a video, here

make depends

Dependency Management
The irony of Makehttp://www.ddj.com/linux-open-source/184406479




Advanced Auto-Dependency Generation
http://make.paulandlesley.org/autodep.html

The Linux Kernel API

Documentation on many of the kernel API calls, with some searching I Found some excellent pages on this.

http://www.gnugeneration.com/books/linux/2.6.20/kernel-api/

http://tldp.org/LDP/lkmpg/2.6/html/index.html

http://kernelnewbies.org/KernelHacking

http://www.advancedlinuxprogramming.com/alp-folder

Linux USB drivers — Understanding and developing Linux USB drivers
Embedded Linux optimizations — Optimizing the Linux kernel and applications for speed, size, RAM, power and cost.
http://free-electrons.com/articles

Advanced Linux Programming
http://en.wikibooks.org/wiki/Linux_kernel

millisecond tick in C++

To compile run
g++ -l pthread -o millisecondtick millisecondtick.cpp

Turned out I had to use one static member function to jump off onto another to get up and running.

/* millisecondtick.cpp
 * Creates Millisecond Tick 
 */

#include 
#include 
#include 

#include "millisecondtick.h"

MilliSecond_Tick::MilliSecond_Tick(){
   Running = FALSE;
};



void* MilliSecond_Tick::runx(void *pMilliSecond_Tick){

    ((MilliSecond_Tick*)pMilliSecond_Tick)->run(NULL);
}



int MilliSecond_Tick::start( pFnVoid func ){

pFnVoidVoid  prun;

 
  prun = runx;
 
   if (MilliSecond_Tick::Running != FALSE){
     printf("Error MilliSecond_Tick already started, can not start second instance\n");
     return 0 ;
   }

  callback = func;
  pthread_create(&tid, NULL, prun , this);
    Running = TRUE;

  return 0;
}




void MilliSecond_Tick::stop(){
MilliSecond_Tick::Running = FALSE;
pthread_join(tid, NULL);

}


void MilliSecond_Tick::tick(){
  (*callback)(); 
}


void* MilliSecond_Tick::run(void * nothing){

    struct sched_param sparam;

    sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
    if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sparam) == 0) {
                        // success, this application has sufficient privileges
    }
    else {
            // setting priority failed, probably due to insufficient privieges
    }

    for (;;) {                           // for-ever loop of the ticker thread
        static const struct timespec nanowait = {0, 0*1000*1000};    // 1 ms
        nanosleep(&nanowait, (struct timespec *)0);

     if (Running == FALSE){
        break;
 }

        tick();
    }
}



void tickss( ){
 static int x = 0, y = 0;
x++;
  if (x > 1000){
     x = 0;
     y++;
     printf(">%d\n",y);
     } 
}



int main(){

 MilliSecond_Tick cmt;

 cmt.start(&tickss );

 sleep(10);
 cmt.stop();

}

// millisecondtick.h

#include 

#define TRUE 1
#define FALSE 0 

typedef void(*pFnVoid)();
typedef void*(*pFnVoidVoid)( void *);

class MilliSecond_Tick
{
  private:
    int  Running;
    pFnVoid callback; 
    pthread_t tid;
    static void *runx(void *pMilliSecond_Tick);
    void tick();
  public:

  MilliSecond_Tick(); 
  ~MilliSecond_Tick(){};
  int start( pFnVoid func ) ;
  void stop(); 
  void * run(void * nothing);
};

Wednesday, September 30, 2009

Virtual Hosting and other hosting.

http://www.tektonic.net/ is offering Linux hosting starting at $15 a month. You get to be root on your own virtual server.
starts at 20Gig, disk space seem very expensive from them as you expand.

I am running 2 Co-Lo's now on FreeBSD. They never have problems, but it's an interesting prospect to get a virtual server, one of my friends is moving off the free Colo to one, basically because it offers compartmentalization for his customers.

IPOWERWEB  offers dedicated server hosting for $129 a month

But they offer regular FreeBSD web hosting through there GUI interface for $5.95 a month, I have a program on source forge rtelnet that allows you to open shell access on there web hosting accounts but there isn't much you can do on there boxes. Still it will run FreeBSD binaries that you can compile at home and upload to the CGI dir.
NOTE: I deliberately put a very simple bug in rtelnet to keep out the kiddies. It's really easy to fix. But I just don't want this to get misused by people that are really clueless.


Other interesting crap to put on the virtual server. 

FROM Wiki - Fetchmail  is an open-source software utility for POSIX-compliant operating systems which is used to retrieve e-mail from a remote POP3, IMAP, ETRN or ODMR mail server to the user's local system. It was developed from the popclient program, written by Carl Harris.  Its chief significance is perhaps that its author, Eric S. Raymond, used it as a model to discuss his theories of open source software development in a widely-read and influential essay on software development methodologies, The Cathedral and the Bazaar.

Web GUI mail packages (it's PHP)
http://www.horde.org/
http://www.horde.org/imp/

Horde is a PHP-based Web application framework.

It offers applications such as the Horde IMP email client, a groupware package (calendar, notes, tasks, file manager), a wiki and a time and task tracking software.

Monday, March 17, 2008

frustrating



Reading computer manuals without the hardware is as frustrating as
reading sex manuals without the software.
Arthur C. Clarke



Where do I begin. I am forced further and further from BSD land into Linux. Where completely messed up ways of doing things seem to be the norm.
Work queues, kernel threads, and the like seem fundamentally wrong to me. We just dealt with a dead lock condition in the USB Gadget driver last week. Still struggling to understand what is causing spurious interrupts on the MMC driver in this 2.6.15 Linux Kernel we are running on an ARM platform. Odd think is that it's fine in debug mode, just happens in non-debug. Murphy's law certainly applies here. This whole Initrd business is just messy also.

But it's not all griping about Linux, I just set up a New 1TB FreeBSD 6.3 based server. Somehow I feel like that project has taken a turn for the worst. As much as I didn't really care much for Jordan Hubbard, he did manage to do a good job of things overall.
I thought I'd try some new tricks on the box, since it's in a CoLo some 500 miles from home it's a little hard to operate, and rebooting and moving cables or pressing F1 at boot time is just not going to happen.
So I installed Xvnc, very cool thing, usually I'd just open X-terms across the net to work, or more lately tunnel Xterms over ssh, ssh -R 6001:127.0.0.1:6000 sokol@192.168.1.116 http://x.unixprogram.com/ Someday I will make a real site out of that.
Then I bring up olvwm and Firefox. Now overall this is very cool, since I can leave all my Xterms open and connect using VNC and my whole desktop is right where I left it even though I changes locations and computers, even screen resolutions.
My gripe is FireFox on FreeBSD is just 1/2 operations compared to where it's at on Linux.
Or maybe I should say the FireFox is fine, but lacking operational plug-ins.
I just haven't been able to get Java and Flash, or Acrobat working right, in Ubuntu this is a no brainer. In addition Firefox is spewing a stream of error messages at the console that I opened it with. I am not a happy camper, that's for sure.
Now overall I swear by firefox, and the fact that none of these companies or Firefox itself is really paying much attention to FreeBSD is disturbing, maybe even a lack of diplomacy that used to exist under Jordans participation. Mozilla used to do a good job with FreeBSD support including most plugins. Maybe I Need to turn on Linux Support in the BSD kernel and run all linux binaries. Yuck.

On another note. I have found it interesting at the response I get from Linux people. I find I can still run circles around most of them even being someone out of place in the Linux Kernel, but already I have my name in the 2.6.17 kernel and later on the ViVi driver. I have done about half a dozen driver since then. And having had come from a Pre-threaded kernel world, I can do much better jobs at driver interrupts and getting things to work better for real time stuff.

Oh there is also some really interesting TCP/IP socket call stuff I came across to, specifically how long a process spends doing a "write" or "Send" call. It's very different then I had expected. and Both FreeBSD and Linux exhibited similar behavior. This was that even Non-blocking calls can take a very long time to write. Something on the order of 200+ uS. Didn't seems to matter if it was blocking or non-blocking either. And it took even longer with Nagel disabled!.
Blocking was only fast if the socket was really going to block, then the non-blocking would return in 1uS or less even!
200 Micro Seconds, heck that a long time. What the hell is the kernel doing for that time, and it seems to be burning up CPU that whole time no less. I alway just assumed it would take that buffer and put it in some queue and return immediately.
Anyhow that for was 100 to 1000 bytes sends at 1 second intervals.
When I started sending data full out at 10Mbps or higher, this delay for the write calls dropped down to 2ouS or less even. How is that for odd. the more data I send the faster the send call gets! Exactly opposite of what I would have expected.

Monday, July 09, 2007

Please don't spam in my comments here.

I can't believe people are spamming into blog comments now.
It's there no end. I don't want your stock, Viagra, mass mail service, hoodia, Rolex watches or what ever other crap your selling, nor do my readers want this.

On that note, go to my sites and click on all the Google adds you can please.

Seriously, I have Unix Program.com and C-program.com for some notes on programming and development. Unix program also has a good image collection, please don't link to these from your myspace page.

As much as I am pro-BSD, I have had to start doing more and more Linux development. My name is in the Linux Kernel since 2.6.17 on the VIVI driver.

I guess at some level they are on the same side of the battle as us BSDers.

"I must say the linux community is a lot nicer than the unix
community. a negative comment on unix would warrent death
threats. with linux, it is like stirring up a nest of butterflies."

-- Ken Thompson. 1999

Checkout my junk box /dev/null

And also my Main Blog http://johnsokol.blogspot.com/