freebsd 8.2 install notes for 880GMA-UD2H

This motherboard has AMD 880G chipset ( with Ati Radeon 4250 graphics card ) and
FreeBSD 8.2 doesn’t give out-of-box drm support for this card.
I don’t expect playing games but without it i was not able to watch movies at full-screen.

There is a solution ,
but i couldn’t find those files in my installation.
After some searches and using same logic,
i added the last line below to the /usr/src/sys/dev/drm/drm_pciids.h file.

{0×1002, 0×9713, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP, “ATI Mobility Radeon 4100″}, \
{0×1002, 0×9714, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP, “ATI RS880″}, \
{0×1002, 0×9715, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP, “ATI Radeon HD 4250″}, \

After building kernel, xvinfo was able to return detailed info and
mplayer was playing videos at full-screen but maybe 3-4 times faster than normal and there was not sound.
Someway this is related audio device.
Adding this line below to the /etc/sysctl.conf file solves the problem.
hw.snd.default_unit=1

.emacs for sbcl and slime

Times ago i had some experience with Emacs.
It was a total frustration (but feeling to be a part of a legend)
Vim had a steep learning path too
but it was paying back at the end.

Later i am interested in Common Lisp
So obviously Slime and Emacs.
And i believe this was the first time i met Emacs.
It’s not meant to be an text editor,
It’s a lisp editor, compiler, interpreter and
a RCP (Rich Client Platform) for Lisp applications.

When i watch some videos about lisp machines of symbolics,
i totally changed my view of what Emacs stands for.

I will put my .emacs settings here,
so i wont have to search them again and again after a new install :


;;
(fset 'yes-or-no-p 'y-or-n-p)

;; no startup screen
(setq inhibit-startup-screen t)

;; no-tool bar
(tool-bar-mode nil)

;;
(show-paren-mode 't)

;; cua selection
(cua-selection-mode 1)
(put 'erase-buffer 'disabled nil)

;; SLIME - BEGIN

;; HyperSpec documentation
(setq browse-url-browser-function 'browse-url-firefox)
(setq common-lisp-hyperspec-root "/usr/local/share/doc/clisp-hyperspec/HyperSpec/")

;; Required If you use utf-8 strings.
(set-language-environment "UTF-8")
(setq slime-net-coding-system 'utf-8-unix)

(add-to-list 'load-path "~/.emacs.d/plugins/slime")

; sbcl with less memory consumption
(setq inferior-lisp-program "/usr/local/bin/sbcl --dynamic-space-size 100")

(require 'slime-autoloads)
(slime-setup '(slime-fancy))

(global-set-key [f12] 'slime-selector)

;; SLIME - END

Singleton Pattern in java, i saw the Monster.

I was re-factoring an open-source project for fun.
I found file backed configuration classes which are singleton in nature
and they were implemented in a look-like-singleton way
i decided to convert them all into Singleton.

Since it doesn’t need synchronization and
those configuration files needed at start-up not subject to lazy initialization
I preferred static final member and private constructor solution.


class Singleton{

private Singleton(){
...
}

private final Singleton instance = new Singleton();

public static Singleton getInstance(){
return instance;
}
}

class had a member named doc which is initialized inside a method init()
this method is called by constructor.

...
private Document doc;

private Singleton(){
init();
}

private void init(){
doc = ....
}

Code seemed okay but was failing “magically”,
Singleton.getInstance().getDocument() was giving a null doc instance.

After some digging,
I realized that code inside the constructor was just ignored,
Debugger didn’t care break points
whether inside constructor or init() too.
Even throwing a RuntimeException inside constructor had no effect.

i searched about that issue
only found some information about tomcat and jboss may fail in that situation :
http://www.c2.com/cgi/wiki?JavaSingleton

This last approach seems to work well in most cases — and perhaps it is supposed to work per the Java spec. But — as I’ve recently learned the hard way — both Tomcat and JBoss do not always execute this code correctly. In particular, if some code is placed in the body of the constructor, even something trivial like logging to System.out, it is not always executed. I’ve also had initialization of member variables silently fail in the constructor. Unfortunately, deadlines have driven me to seek workarounds rather than research this situation. I’d love to learn more about it, even if that means learning I’ve made some big dumb mistake in what I was trying!

doesn’t give the reason (at least i am not alone.)
NOTE : The code i was working on was swt-powered desktop application ( although tomcat’s servlet-api.jar was in my classpath ).

It’s obviously a bug somewhere
but i can not dare to report it ( first i should isolate the part of code reproduces the issue ).
but if someone interested
i will give the road-map i was on
maybe you’ll see the monster too. ;)

java as a portable application.

When i first installed ubuntu, gcj was the default “java provider”.
Java applications were depending on this package and
i was in doubt to uninstall it.

First i went through update-alternatives –config java
which was a mistake.
( Do you know how many java related things we have ? )

update-alternatives –config java
update-alternatives –config javac
update-alternatives –config javap
update-alternatives –config javah
update-alternatives –config javadoc
update-alternatives –config keytool
update-alternatives –config policytool
update-alternatives –config jarsigner

etc.

i discovered later update-java-alternatives does the job.
It seems people are confused about it
a lot of websites are still advising the first form.

But the real point was :
“who want to have a mixture of java tools from different platforms ?”
Why not a single step and “best known form” of the command :
update-alternatives -config java-platform-or-whatever
( maybe a new command for ‘freaky’ installation scenarios )

Those times ubuntu didn’t like the java license.
Nowadays open source java from sun became default.
But it’s worth to notice,
ubuntu always were providing proprietary graphics-card drivers
with an oversimplified installation procedure.

After installing tomcat,
i faced their fashion of deploying things was different than i was familiar.
Tomcat’s files/folders were scattered over different places.
And the JRE/JDK installation, there were symbolic links inside /usr/bin to java executables .

It may be obvious to search a server configuration file
under /etc/ directory for a linux administrator,
moving logs and web applications under /var directory ( and probably on a different partition ) also.
But missing the point :
“java and tomcat are portable in nature”.

I believe all those “policies” doesn’t fit well with java
and decided to put my complaints in public:

  • /usr/bin is available for everyone.
    Its practically impossible to force a particular user to another java runtime.
    We can add ANOTHER_JAVA to the user’s PATH,
    but its easy to by-pass.
    We may change file permissions for /usr/bin/java or
    changing permissions of java installation directory it points
    but both of them makes those symbolic links pointless to be there.
  • Proper way to put java executables into PATH is
    adding them as export PATH=”$JAVA_HOME”/bin:$PATH.
    Java executables under /usr/bin and a JAVA_HOME variable (possibly pointing somewhere else)
    rise an unnecessary configuration duplication.
    Scripts which checks JAVA_HOME will run one JVM, direct calls will run another JVM.
    It’s confusing !.
  • Default place for java.security and java.policy files which should be somewhere under $JAVA_HOME now will be pointed by /usr/bin/java found in PATH.
    Same as above it’s not possible “safely” to set different security policy files for different users.
    And again confusion !.
  • Tomcat, when you want to have different instances of it
    you challenge with the “policy”.
    Simplest way is not to install java and related things as ubuntu packages.
    But what about applications depends on them,
    is there a way to make apt happy with “seems unsatisfied” but perfectly complete dependencies ?

    I switched to slackware linux since they are promoting upstream-defaults.
    i found no symbolic links inside usr/bin or whereever.
    JAVA_HOME and PATH was set properly by /etc/profile.d/jdk.sh script.
    There was not a tomcat package ( and definitely there is no need for it )
    i downloaded and unpacked it under /opt/.
    Just a need to set CATALINA_HOME environment variable.

    Portable application logic make things simple.
    We may have different java virtual machines for different purposes.
    same as different version and/or configurations of java application servers.
    Just we need to copy the application folder somewhere else and
    setting some environment variables and file permissions.

sources of evils in concurrency.

I found a nice entry about three important concepts in concurrent programming by Jeremy Manson.
http://jeremymanson.blogspot.com/2007/08/atomicity-visibility-and-ordering.html
atomicity, visibility and ordering…

I wanted to add some extras: side effects of optimizations and data duplications .
These two sources of evils play an important role on concurrent programing.

  • Atomicity is important for data integrity.
    When objects transit from one state to other,
    they should not expose the moment in which invariants are broken.

    girl comes in to the room and catch her boyfriend
    he was half-naked and hugging another girl.
    she got pretty upset and run away without saying anything.
    but however it was a misunderstanding,
    there wont be any problem if she was there a few seconds before or few seconds later.

    Another prominent area of the concept is Databases.
    Database programmers use transactions and transaction isolation levels,
    to achive both acceptable correctness and performance.

    This sort of problems are hard to figure out,
    but they have logical explanations in source-code-level.

  • Visibility is a hidden enemy.
    In source-code-level, there is not any reason why it happens.
    But it’s related both optimizations and hardware-design.

    There are several levels of memories.
    Fastest ones are more expensive and they are embedded into cpu.
    If data resides on the fast one, code will run faster.
    So it’s desirable, compilers get benefit of that fast memory as well as much.
    But since this special memory is very limited in size,
    most of the code will reside on slow memory.

    Parts of data will be copied to faster memory on demand,
    processed(probaby changed) and copied back to the slower one.
    This means : our data is duplicated between different kind of memories in runtime.
    ( also computers may have more than one cpu, means more duplications. )

    Altough it does not cause any problem in single-threaded applications.
    Concurrent applications are not protected by default.
    Without proper syncronization, threads may see the stale data.

  • Ordering another result of optimization.
    Compiler re-organizes the instructions into more efficient ones.
    It’s understandable, we mostly re-organize instructions in daily-life.


    mom’s shopping instructions :
    - buy 6 eggs.
    - buy 3 package of margarine.
    - buy 1 bread.
    - buy 6 eggs more.
    - leave back 2 packages of margarines, it’ too much.
    - buy 1 bread more.

    actual shopping list:
    - 2 breads (i buy them first, becos they are in the enterance.)
    - 12 eggs.
    - 1 package of margarine.

I want to suggest this great book for java developers,
i was totally blind before reading it.

is something wrong with JUnit ?

When a test fails, Junit throws an java.lang.AssertionError
same as when java build-in assert statement fails.
So if you have assertions in your code,
be ready for surprises.

Assertion in my code is :
assert timeout > 0;
my test is passing whether or not timeout > 0
can you see the problem :

@Test
public void constructor_invalid_timeout() {
    long timeout = -1;

    try {

        new AbstractInquiry(timeout){
            @Override
                protected Object getResponse() {
                    return null;
                }
            @Override
                protected void progress_hook() {
                    //no progress
                }
        };
        // ********* FROM HERE  *****************
        fail("assertion failed : timeout > 0");
    }
    catch (AssertionError e) {
    }
        // ********* TO HERE  *****************
}

JUnit throws an AssertionError which its not defined by JUnit.
( so it’s not reserved to JUnit. )
Even further :
Is it safe, a testing framework throw any kind of Exceptions or Errors ?

Note:
I know it’s disapproved to use ‘assert’ statements validating public method arguments.
but it’s another story, coming soon ;) .

www.myjavaserver.com free java web hosting .

www.myjavaserver.com
Answer the question, get an account.
Opera users be carefull !! page ( compile text area ) is not working in Opera.

They are giving 5MB of storage, no bandwidth limit mentioned.
Their server responsing fast, after sign-up, you will have a ftp account.
Also You can use jsp, mail-server, and database.

I had some problems the day i activated my account related jsp compiler.
Also i didnt like the deployment logic their server required which is not standart.
But they claim they are working on to provide .war deployment support.

I have only some html pages on my account.
http://www.myjavaserver.com/~mr1yh1/

Free Solaris DVD Kit from SUN

Sun is sending their famous operating system Solaris 10
via mail for free. ( similar to what Ubuntu project did ).http://www2.sun.de/dc/forms/reg_us_2211_391.jsp

They say it’s a limited-time offer.
This offer is valuable specialy if you have not a fast and unlimited net connection.
Solaris was free since june 2005.

There are 2 options you can choose:

Sun Solaris 10 :
it’s cost-free OS from Sun.
Solaris Express :
Open Solaris based , it includes some developer resources. But if you ask for only Solaris 10, you wont miss anything since all of them freely available from Sun.

As well as i know, open-sourced part of the Solaris named as open-solaris.

yine, yeni, yeniden CD DVD problemleri…

Bilgisayarınızdaki en sorunlu alet CD/DVD okuyucu değilse,
bu cihazı pek fazla kullanmadığınızı düşünürüm.

CD/DVD diskler, ne kadar özen gösterirseniz gösterin
hatalı yazılabilir, okunurken çizilip işe yaramaz hale gelebilir.
CD/DVD cihazları ise birkaç sene içerisinde ömrünü doldurur.

Şimdiye kadar kaybettiğim veri miktarı, doğru okuduklarıma yakındır.
Bunların çoğunu ben yazmamış olsamda sonuç değişmiyor.
Bu medya tipine güvenmiyorum.

Peki neden kullanılıyor CD/DVD…
Çünki artık tarih olmuş floppy ler kadar bile güvenilir olmayan bu optik medya,
maalesef günümüzün en ucuz veri depolama alternatifi.

smart-card, USB flash disk, harici harddisk gibi seçeneklerin,
depolama maliyetinin ucuzlayacağı,
hızlı ve ucuz internet bağlantısı sayesinde
veriyi kargo paketleri ile iletmek zorunda kalmayacağımız
günleri hayal ediyorum.