Sunday, November 9, 2014

Shared Memory (Inter Process Communication) / PROGRAMMING

Unknown
INTER PROCESS COMMUNICATION (IPC)

Hii, semua kembali lagi bersama saya Harry...Karena tuntutan untuk memajukan bangsa dan generasi muda, maka saya akan memakai Bahasa Indonesia untuk membuat postingan-postingan selanjutnya :D (Sorry for international readers, from now on I'll be using my mother Language "Bahasa Indonesia" for my future postings. Maybe you can translate this post via Google Translate!!Enjoyy :D)

Setelah kemarin kita telah membahas bagaimana cara meng-instalasi Linux via Vbox by Oracle, saatnya kita fokus pada sistem yang dijalankan pada Linux). Pada dasarnya, Linux adalah sebuah Open Software jadi kita lebih leluasa untuk mengotak-atik sistemnya, khususnya para programmer yang ingin lebih mengambangkan linux sesuai "cita rasa" yang mereka inginkan. Tidak dipungkiri, bahwa banyak sekali model-model distro Ubuntu di dunia, hal itu berkat para programmer yang terus mengeluarkan Linux versi mereka sendiri. Well, kita belum akan membuat Linux versi kita sendiri. Tapi paling tidak kita bisa mengutak-atik sedikit dan menggunakan sistem Linux yang ada untuk keperluan kita :D

Inter Process Communication --> Komunikasi antar Proses

Pada dasarnya proses adalah program yang sedang di eksekusi. Nah, tidak dipungkiri bahwa kadangkala ada 2 proses yang sedang berjalan bersamaan/bergantian dan kedua proses itu menggunakan resource yang sama. Maka dari itu kedua proses ini, butuh saling berhubungan untuk menggunakan resource itu. Bagaimana cara berhubungannya?:O

Of course, dengan menggunakan IPC tadi. IPC modelnya ada banyak, misal:

  • Shared Memory
  • Processes Semaphores
  • Mapped memory
  • Pipes
  • Sockets
Diatas adalah beberapa contoh dari IPC dan nantinya kita akan lebih mendalami tentang Shared memory...(yang lainnya cari sendiri di google yaa, banyak kok :p)

Biasanya untuk model penggunaan IPC ini, kita memakai classical problem yaitu client-server. Problem ini didasari pada proses Server yang mengupdate jumlah barang misal dan Client  yang mengambil barang. Nah, kedua proses ini harus saling berkomunikasi supaya saling tahu. 

Belajar pada bidang Computer Science sebenarnya adalah hal yang mudah. Mengapa? Karena komputer dibangun untuk memudahkan hidup manusia dengan melihat kebiasaan-kebiasaan / problem klasik yang harus diselesaikan oleh manusia. Misal pada problem Client-Server hal itu seperti ada seseorang yang pergi ke sebuah toko dan di toko sana si pelanggan ingin membeli sebuah barang. Maka pelanggan tersebut akan bertanyak kepada toko apakah barangnya ada? dan jika ada maka client akan membeli dan stok toko pun akan berkurang. 

Nah proses komunikasi itu lah yang dalam computer science kita sebut IPC atau Komunikasi antar Proses.

SHARED MEMORY

Mengapa menggunakan shared memory?
  1. Paling cepat dari semua IPC
  2. Easy to implement
Shared memory merupakan IPC yang paling cepat, karena proses-proses yang ada hanya menggunakan 1 blok memori yang sama. Jadi tidak ada proses peng-kopian atau segala macam lainnya.

Shared memory juga sangat mudah untuk diemplementasikan. Mengapa? Jika anda seorang programmer dan mengenal Bahasa C, maka shared memory ini sangat mudah untuk dibuat dalam sistem karena hanya mengandalkan pointer-pointer saja. 

Memory Model

Karena kita akan menggunakan blok/segment pada memori untuk mengaplikasikan Shared Memory ini, maka kita harus melakukan attach dan deattach pada memori. Jangan lupa, kita juga harus meminta alokasi memori/mengalokasikan memori untuk variable/fungsi yang akan digunakan bersama-sama dengan proses lain.

Mari kita mulai dalam programmingnya...
Yang anda butuhkan:
1. Library C-nya

Untuk membuat sebuah shared memory, C telah memberi kita librarynya, yaitu #include<sys/shm.h> -->shm=shared memory dan #include<sys/ipc.h> -->untuk IPCnya (karena shm merupakan IPC)

2. Fungsi-fungsi yang ada dalam #include<sys/shm.h>

int shmget(key_t key, size_t size, int shmflg);

key_t key == angka terserah sebagai identifier segment memori anda
size_t size == berapa size yang anda berikan untuk 1 segment memori (dalam kasus ini tidak terlalu besar, karena kita hanya menggunakan sebuah variable integer (4 bytes))
shmflg== IPC_CREAT dan IPC_EXCL, IPC_CREAT kita gunakan untuk membuat segment memorinya dan ('| 0666') itu adalah sebuah pipe yang menandakan bahwa segment ini boleh di read dan write (6)

void *shmat(int shmid, const void *shmaddr, int shmflg);

Nah, karena shmat sendiri adalah sebuah fungsi pointer, maka disimpannya juga harus di variable pointer juga yaaaaaaa...

shmid== apa yang anda dapat dari shmget  di atas..Namanya aja 'get' nah pasti dia mendapatkan suatu nilai integer berupa identifier dari segment tadi..
shmaddr==jika NULL maka sistem akan menggunakan unused address untuk men-attach segment tadi.

Selebihnya hanya pointer-pointer biasa yang menunjukkan memori, karena anda-anda (pembaca ini) adalah programmer, diharapkan anda mengerti sendiri mengenai apa yang saya coding dibawah :P

SERVER_TOKO.C



Untuk membuat program client-nya, anda tinggal men-copy proses pembuatan shared memorynya sama persis seperti di atas. Mengapa? Kan tadi sudah kita ketahui, bahwa memorynya dipakai bersama-sama, jadi ID memory, dkk. nya juga harus sama persis, supaya client juga tahu.

CLIENT_TOKO.C




Dari kedua program di atas, maka server akan dapat menyimpan barang-barang yang ia miliki di satu memori, sehingga nanti pada saat ada client yang mengakses, yang diakses adalah segment memori yang sama. Jadi ketika ada perubahan yang dilakukan oleh client/server pada segment memori yang dipakai bersama-sama tadi maka kedua belah pihak dapat mengetahui perubahan itu.

Perlu digaris bawahi, bahwa kedua program di atas tidak mungkin terjadi RACE CONDITION , karena kedua program di atas hanya dijalankan pada satu komputer yang sama (tidak mungkin anda mengisikan secara bersamaan pada program client dan server). Lain cerita jika anda menjalankan 2 program di atas pada 2 komputer/many computer yang berbeda. Anda harus memperhatikan Race Condition-nya...Mungkin dengan menggunakan semaphores atau lainnya..

Semoga postingan saya kali ini bermanfaat yaaaa.....Tunggu postingan selanjutnyaa...Dijamin lebih seru daripada topik yang ini..Enjooyyyy :P




Monday, October 6, 2014

Installing Linux on Your Computer

Unknown
Hi there, you must be waiting for me to post this publish on how to install linux right on your computer. There are two ways to install linux on your desktop: first, is you can install it by dual boot, so right after you booting your coputer you'll see the list of OS in your computer (in this area, let's say you'll have Linux and Windows). Second, you can install linux by virtual machine software. A vrtual machine, is a software that can allow you to use Windows and Linux at the same time by taking one of them go virtual. There are many virtual machine software you can get from the internet, e.x.: VMware, VirtualBox, QUEMU, Bachs etc. We'll install our Linux OS using the second way by virtual machine software at this moment we'll use VirtualBox from Orcale, Inc. because it's FREE!!!hahahhahaa. Here's the link VirtualBox downloads, and you can choose what OS you're running now. I'm running in Windows 8.1 so, i'll choose the first one.

It'll take a few minutes. After that you just click "next" until you're finish. Easy right? Now, let's concentrate on the step.

STEP 1: Download VirtualBox (we've already done it, in case: VirtualBox downloads) and install it. Almost forgot, don't forget to download Linux from internet!Simply search on search engine GOOGLE and type what linux kernel you want to use. Example, you want to use Linux Mint, here's the URL LINUX MINT. Just some information, all Linux based OS is FREE, so you can download it right through internet.

STEP 2: Click on the "new" button on your VirtualBox and you'll see



 Name the OS in the name coulumn (It's up to you, e.x.: Linux-mint, Linux-1, LinuxGreat). In this case, i'll try to virtualize Linux Mint. So, select your OS type (Windows, Mac, Linux) and choose their version (Windows 8, Mac OS Leopard, Ubuntu). We'll choose Linux and our version is Ubuntu. Basically, Linux Mint is Ubuntu and Debian based, but you can also search Linux Ubuntu. It's quite popular too. Just you know, there are so many version of kernel in Ubuntu. There are fedora, debian and etc. And so many versions are make based on that kernel. So, don't confuse about that. Oh yeah, this is my experience, you must choose your Version between 32-bit or 64-bit based on your computer architecture. Too see that,if you're using Windows simply type dxdiag on run box (search 'run' program on your computer). By the way, to compatible with that, you also MUST DOWNLOAD your linux version based on your computer architecture. Basically, 64-bit computer can run 32-bit application, but 32-bit can not run 64-bit application. In some case (my case actually), I've downloaded 64-bit version of Linux Ubuntu, but the 64-bit version doesn't list on the VirtualBox. It's because your Virtualization chip on your computer is disable. Then, you must enable the virtualization chip. My chip is Intel so, on your laptop go to BIOS Settings (Windows 8: Change PC Settings --> Update and Recovery -->Recovery-->Advanced Settings-->UEFI Firmware Settings). After you can acces your BIOS, check for Intel Virtualization Technology and set it to enable. And enter your Desktop again and open VirtualBox, now you'll see the list of 64-bit version.


enable your Intel Virtualization Technology (if your chipset is Intel)

STEP 3: Choose how many memories (RAM) you'll give for your Linux. 1024 MB = 1GB 2048 MB= 2GB. Bigger you give, less lack on your virtual OS.


STEP 4: Now, we'll try to setting the hard disk. After you finish setting your amounts of RAM, you'll get to this step.

Select to create virtual hard drive for your new virtual OS.
Choose dynamically, so you can settings how much byte will you give for this virtual OS.

STEP 5: CHOOSE LINUX ISO FILE

ISO file is the on you've downloaded in the beginning of this section (downloaded from Linux-Mint website). Probably, you haven't finished downloading yet, because yes  it is fantastically BIG SIZE!!

Let's go to finish downloading step :p

ISO file is a file that store all your information about OS. In the past, if we want to install OS/program on our computer we must have "INSTALLATION DISC", it can be CD-ROM or DVD-ROM (familiar right?). But now, in this era we don't have to use that anymore, because all of that is store in file called .iso file. To start your OS using virtual box, simpy go to

SETTINGS-->STORAGE-->CLICK ON CD ROM IMAGE to PUT YOUR ISO FILE


after that, you'll see your Data storage on your computer and choose the file you've finished downloaded from LINUX website (is the file with .iso e,x, linuxmint-15-cinnamon-dvd-32bit.iso) and click OK.

Now, you've finished with the hardware settings. Click on START button to LAUNCH your system.



STEP 6: INSTALL LINUX AND MAKE ACCOUNT FOR ADMIN

Because you're running on Virtualize mode, simply click "NEXT" until you are ask for make an account. In one step, you'll ask to erase disk and install Linux, don't worry about that just keep clicking "NEXT" remember you're running on a virtual mode so your data is not recognize on their virtualize system. 


This is some of the advantages using Virtual Software to run Linux. Linux is very difficult OS to install, especially if you want to dual boot with windows 8. My experience is, all my drive on my PC was erased by Linux. My data and also my Windows 8.1, then i must re-install it again T.T. But don't worry if you're running on virtual, this case is never going to happen.

After you finish entering your account and you are also finish installing your LINUX!!!!CONGRATULATIONS :D:D:D Probably, this is your desktop on Linux-Mint!!


Okay, we'll end this tutorial about "HOW TO INSTALL LINUX using VirtualBOX".Hope you make it, and just wait for my next publish about anything in computer world. Enjoy :D

Sunday, October 5, 2014

LINUX OPERATING SYSTEM

Unknown
Hi...I'm back..It's been a few months since my last published about my self, and now I'm back with some interesting topic about LINUX. Do you know Linux?If you don't know about them, you are actually don't know about one of the most best Open Source OS in the world. Yes, LINUX is an open source OS and it's FREE!!!!!!!Everyone like free product, don't they? I make a bet, that you just know Windows for your laptop or some Mac OS and android, windows phone and iOS for your smartphone. Linux is basically from UNIX OS, just like the most expensive PC OS == MAC OS from Apple, Inc (you must buy their laptop first to get Mac OS). Yes, if you know UBUNTU from LINUX, its UI(User Interface) just like MAC OS from Apple. This is some screenshot in Ubuntu Desktop
(Source: http://www.omgubuntu.co.uk/wp-content/uploads/2014/04/ubuntu-desktop.jpg)

Just some information, Ubuntu is a Debian-based Linux OS, and its UI is just like the Mac OS, because Linux and Mac OS is a UNIX-based OS. Some of the best feature in Linux is you also get open souce application such as (LibreOffice Writer, Calc, and Impress) they're just like Word, Excel and Powerpoint from Microsoft, but the different is it's all FREE!!!!Can you imagine that?You can make some word document (.doc/.docx) using this application and you don't pay for that! Some additional feautres of an open source OS are you can make change to the OS, settings the systems by your own and etc. Interesting in Linux?Just wait for my next publish!We'll learn how to install Linux on your computer!

Sunday, July 20, 2014

This is me

Unknown
Hello everyone..

Let me introduce myself.



My name is Hariyanto, you can call me Harry.I'm 20 y.o. boy and I had passed my second year college, majoring in Computer Science at Sepuluh Nopember Institute of Technology (its.ac.id) in Surabaya, Indonesia. I'm a very open person, you can ask me anything or you may ask me for help then I'll be very generous to help you as far as I can.

You can send me some questions on my e-mail thenewmailofharry@yahoo.com, add my facebook Harry Tan, and follow my instagram amazingharry95.

Enjoy your time in my blog!

"Education is the most powerful weapon which you can use to change the world." - Nelson Mandela

Powered by Blogger.

Text

Popular Posts