// API callback
av({"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-3716092791552935940.post-1822448081952849132"},"published":{"$t":"2014-11-09T16:49:00.001+07:00"},"updated":{"$t":"2014-11-09T16:52:37.415+07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Linux"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Tutorial"}],"title":{"type":"text","$t":"[TUTORIAL] Shared Memory dalam Linux Bahasa C"},"content":{"type":"html","$t":"\u003Cspan style=\"background-color: white; color: #292929; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.2000007629395px;\"\u003EHai =))\u003C\/span\u003E\u003Cbr \/\u003E\u003Cbr style=\"background-color: white; color: #292929; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.2000007629395px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #292929; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.2000007629395px;\"\u003EKali ini, saya akan menjelaskan tentang shared memory dalam linux menggunakan bahasa C.\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan style=\"background-color: white; color: #292929; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.2000007629395px;\"\u003EPreprocessor Directives yang diperlukan adalah\u003C\/span\u003E\u003Cbr \/\u003E\u003Cblockquote class=\"tr_bq\"\u003E\u003Cspan style=\"font-size: x-small;\"\u003E\u003Cspan style=\"color: #292929; font-family: Courier New, Courier, monospace;\"\u003E\u003Cspan style=\"line-height: 18.2000007629395px;\"\u003E#include \u0026lt;sys\/types.h\u0026gt;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/blockquote\u003E\u003Cblockquote class=\"tr_bq\"\u003E\u003Cspan style=\"font-size: x-small;\"\u003E\u003Cspan style=\"color: #292929; font-family: Courier New, Courier, monospace;\"\u003E\u003Cspan style=\"line-height: 18.2000007629395px;\"\u003E#include \u0026lt;sys\/ipc.h\u0026gt;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u0026nbsp;\u003C\/blockquote\u003E\u003Cblockquote class=\"tr_bq\"\u003E\u003Cspan style=\"font-size: x-small;\"\u003E\u003Cspan style=\"color: #292929; font-family: Courier New, Courier, monospace;\"\u003E\u003Cspan style=\"line-height: 18.2000007629395px;\"\u003E#include \u0026lt;sys\/shm.h\u0026gt;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u0026nbsp;\u003C\/blockquote\u003E\u003Cblockquote class=\"tr_bq\"\u003E\u003Cspan style=\"font-size: x-small;\"\u003E\u003Cspan style=\"color: #292929; font-family: Courier New, Courier, monospace;\"\u003E\u003Cspan style=\"line-height: 18.2000007629395px;\"\u003E#include \u0026lt;sys\/stat.h\u0026gt;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u0026nbsp;\u003C\/blockquote\u003E\u003Cblockquote class=\"tr_bq\"\u003E\u003Cspan style=\"font-size: x-small;\"\u003E\u003Cspan style=\"color: #292929; font-family: Courier New, Courier, monospace;\"\u003E\u003Cspan style=\"line-height: 18.2000007629395px;\"\u003E#include \u0026lt;unistd.h\u0026gt;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Ca name='more'\u003E\u003C\/a\u003E\u003C\/blockquote\u003E\u003Cspan style=\"font-family: inherit;\"\u003E\u003Cspan style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\"\u003EMisal, saya akan membagikan struct yg saya buat pada server kemudian akan bisa otomatis terbaca di client.\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Cblockquote class=\"tr_bq\"\u003E\u003Cspan style=\"font-family: Courier New, Courier, monospace; font-size: x-small;\"\u003Estruct Memory{\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; int isi;\u003Cbr \/\u003E};\u003Cbr \/\u003Eint main{\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; key_t sharedKEY;\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; int sharedID;\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; struct Memory *data;\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; sharedKEY = ftok(\".\", 'x');\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; sharedID = shmget(sharedKEY,sizeof(struct Memory),IPC_CREAT | 0666);\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; if (sharedID \u0026lt; 0) {\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; printf(\"*** shmget error (server) ***\\n\");\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; exit(1);\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; }\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; data = (struct Memory *) shmat(sharedID, NULL, 0);\u003Cbr \/\u003E\u0026nbsp; \u0026nbsp; data.isi = 100;\u003Cbr \/\u003E}\u003C\/span\u003E\u003C\/blockquote\u003E\u003Cspan style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\"\u003E\u003Cspan style=\"font-family: inherit;\"\u003EKemudian client menuliskan program yg sama dengan server (tanpa \u003C\/span\u003E\u003Cspan style=\"font-family: Courier New, Courier, monospace; font-size: x-small;\"\u003Edata = ...\u003C\/span\u003E\u003Cspan style=\"font-family: inherit;\"\u003E ), maka \u003C\/span\u003E\u003Cspan style=\"font-family: Courier New, Courier, monospace; font-size: x-small;\"\u003Edata.isi\u003C\/span\u003E\u003Cspan style=\"font-family: inherit;\"\u003E pada client akan terisi 100.\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan style=\"font-family: inherit;\"\u003E\u003Cspan style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E \u003Cspan style=\"font-family: inherit;\"\u003E\u003Cspan style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\"\u003ETerima kasih, semoga bermanfaat..\u003C\/span\u003E\u003Cbr style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\"\u003ESampai ketemu pertemuan mendatang =))\u003C\/span\u003E\u003Cbr style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\" \/\u003E\u003Cspan style=\"background-color: white; color: #292929; line-height: 18.2000007629395px;\"\u003E#fantasticschematics\u0026nbsp;\u003C\/span\u003E\u003C\/span\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"http:\/\/www.fanyagriansyah.co.vu\/feeds\/1822448081952849132\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"http:\/\/www.fanyagriansyah.co.vu\/2014\/11\/tutorial-shared-memory-dalam-linux.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/3716092791552935940\/posts\/default\/1822448081952849132"},{"rel":"self","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/3716092791552935940\/posts\/default\/1822448081952849132"},{"rel":"alternate","type":"text/html","href":"http:\/\/www.fanyagriansyah.co.vu\/2014\/11\/tutorial-shared-memory-dalam-linux.html","title":"[TUTORIAL] Shared Memory dalam Linux Bahasa C"}],"author":[{"name":{"$t":"Unknown"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}}});