sources of evils in concurrency.
June 13, 2008
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.
http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601
is something wrong with JUnit ?
June 7, 2008
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 .
February 26, 2007
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
February 26, 2007
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…
December 13, 2006
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.
C/C++ development under Windows using Eclipse.
December 12, 2006
If you are searching a free and quality IDE for C/C++ development,
you may look at eclipse. ( specially if you are a java programmer too … )
check up-to-date versions of software before download.
i keep version numbers for simplicity.
-
first of all, eclipse needs Java Runtime Environment (JRE) installed.
if you want to develop java applications too, install only JDK …
http://java.sun.com/javase/downloads/index.jsp -
JDK downloaders, put java excutables on your path,
( forexample C:\Sun\SDK\jdk\bin in my machine. ) -
smallest size eclipse is Platform Runtime Binary
this does not include plug-ins to develop anything ,
we will download plug-ins later.
http://download.eclipse.org/eclipse/downloads/drops/R-3.2.1-200609210945/ -
install mingw ( gcc for windows ).
download and run MinGW-5.0.2.exe
it will download and install everything needed,
since mingw can compile java, objective C, etc..
no need to check anything else than you needed ( gcc and g++ ).
http://mingw.org/download.shtml -
put mingw executables on your path.
( forexample C:\MinGW\bin in my machine ) -
download and install MSYS-1.0.11-2004.04.30-1
Snapshot, bottom of page http://mingw.org/download.shtml
it will ask your mingw installation path ( C:\MinGW in my machine ) -
put MSYS excutables on your path.
( forexample C:\msys\1.0\bin in my machine ) -
same page, download gdb-6.3-2 for debugging C/C++ programs.
by default it will install inside mingW directory, so no need to add it in path.
otherwise put bin directory in your path. -
to install eclipse CDT ( C development Tools )
- run eclipse,
-
click menu item Help/Software Updates/Find and Install
-
select search for new features to install
-
click on new remote site and add url http://download.eclipse.org/tools/cdt/releases/callisto
-
after some monotonous steps you will see features available
select only “Eclipse C/C++ Development Tools”
hint : eclipse managed C/C++ projects means
eclipse will manage the makefile.
Otherwise we need to write and update a makefile.
after this point you need to learn about eclipse.( look at the help menu ).
some of people dont like eclipse
only becos they didnt spend time to learn about it.
additional info :
http://www-128.ibm.com/developerworks/opensource/library/os-ecc/
killing, suspending, resuming windows executable in command line
December 12, 2006
I needed to stop windows applications from command line
or from a .bat file …
but there is not any utility (maybe i dont know )
similar linux kill command shipped with Windows.
beyondlogic give a free utility process.exe,
just put it somewhere in your path.
(forexample c:\windows\system32 )
http://www.beyondlogic.org/consulting/processutil/processutil.htm
webmin , CentOS , sendmail , “user unknown” error
December 11, 2006
I created a linux user via webmin in CentOS.
username was webAdmin ( which includes a capital ).
i couldnt able to send e-mails to the user.
here is the reason
http://www.cyberciti.biz/faq/linux-usernames-with-capital-letters-not-working/
i changed webAdmin to webadmin, now everything is OK.
here they talk about another solution using the “u” flag in sendmail.cf for sendmail :
http://archives.neohapsis.com/archives/postfix/2000-11/0017.html
i didnt test it, i had better keep them all non-capitals anymore.
simplifying manual control of windows services
December 9, 2006
We may start some services only when we needed.
I have mysql and apache installed as services in my windows machine.
for simplfying to start and to stop.
1-) i set their startup type as “manual” in services window.
2-) i put 2 of .bat files in my desktop
lamp-start.bat dosyası :
net start “Apache2.2″
net start “MySQL”
and
lamp-stop.bat dosyası :
net stop “Apache2.2″
net stop “MySQL”
now its simple to start and stop group of services.
their name may be different in your machine.
look up them in “control panel/administrative tools/services ,
double click and check “display name”…
also its important
if you want to start or stop services which depend each other
be careful about the order, both in start and stop.
this method is specialy usefull for vmware services ( it has 5 services)
in my machine.
—————————————————————-
Bazı servislerin kullanılacağı zaman başlatılması gerekli.
bunları “manual” olarak ayarlayabiliriz.
başlatılması ve durdurulmalarını .bat dosyaları aracılığı ile kolaylaştırabiliriz.
Örneğin, Apache web server ve mySQL veri tabanı ,
makinemde servis olarak kurulu.
Sadece ihtiyaç duyduğumda çalıştırmak için
1-)servisleri manula olarak ayarladım.
2-)iki .bat dosyasını masaüstüne ekledim.
lamp-start.bat dosyası :
net start “Apache2.2″
net start “MySQL”
lamp-stop.bat dosyası :
net stop “Apache2.2″
net stop “MySQL”
servislerin isimleri sizin makinanızda farklı olabilir.
bu işlemi yaparken servisler arasında bağımlılık var ise,
başlatma ve durdurma sırasına dikkat etmek gerekiyor.
cheapest VPS hosting providers i could found , you may add your suggestions below..
December 6, 2006
Web Hosting seçeneklerini değerlendiriyorum.
Hosting firmalarının karmakarışık hale getirdikleri
anlamsız sınırlamalar ( mesala host edilen add-on sitelerin
kendileri tarafından kayıt edilmiş olması zorunluluğu )
ve gizli bedeller içeren “seçenekler” ile boğuşmadan,
gerçek bir serveri yönetmeyi öğrenmek istiyorum.
Bu koşullar altında , VPS (Virtual Private Server) seçeneği,
oldukça cazip bir seçenek olarak ortaya çıkıyor.
Fiyat benim için çok önemli bir kriter,
bu nedenle aşağıdaki linkler bana diğerlerinden cazip geldi.
rimuhosting
eapps
vpsland
vpslink
rapidvps
adiungo
slicehost
veggiehost
amkh (there is not guarantied memory or CPU amount information )
hosteurope.de( seems best specifications, but only in deutch
)
bodhost
eukhost