Newest Post
Tampilkan postingan dengan label System Operation. Tampilkan semua postingan
Tampilkan postingan dengan label System Operation. Tampilkan semua postingan

Kamis, 02 Mei 2019

Docker and Laradock Setup Successful Notes (MAC)(WIN)

Docker and Laradock Setup Successful Notes for MAC (tested)(8 GB RAM)
- For windows you might need extra memory more than 4 GB RAM.
My PC Test Specs :
- iMac (21.5-inch, 2017) i5 - 8GB RAM DDR4
- macOS (High Sierra) v10.13.6

Before starting with laradock, make sure you are creating 1 directory

example setup :

+ laraveldocker
+ + laradock (put laradock inside laraveldocker folder)
+ + yourproject_1
+ + yourproject_2
+ + yourproject_3
+ + yourproject_......

// register that laravel folder in docker preferences
right click docker
> Preferences
> File Sharing
> click "+" / Add
> add that folder (laraveldocker)
- - - in my dir is : /Applications/XAMPP/xamppfiles/htdocs/laravel
> Apply & Restart

// install docker
// error notes ? vm cannot be create
// make sure your memory is big enough
// # # and read this notes : https://sharezone47.blogspot.com/2019/05/docker-unable-to-create-ErrorActionPreference.html

// docker compose build (this is the most fatal things in docker)
$> docker-compose 

// docker compose up
$> docker-compose up -d nginx mysql phpmyadmin redis workspace
$> docker-compose up apache2 php-fpm mysql phpmyadmin
$> docker-compose up nginx php-fpm mariadb adminer

// restart every edit laradock
$> docker-compose restart nginx
$> docker-compose restart apache2

// shutdown all docker laradock instance
$> docker-compose down

// to stop docker // example
docker-compose stop nginx


// see running container (docker and docker-compose)
docker ps
docker-compose ps

// edit host os /etc/hosts and add IP/Hostname mapping
127.0.0.1  laravel.test
127.0.0.1  sheezy.local
127.0.0.1  nonlaravelapp.local

// sites nginx
$> cp laravel.conf.example yoursites.conf

// go inside mysql
docker-compose exec mysql bash
docker-compose exec mysql mysql -u homestead -psecret

// go inside

$> docker-compose exec workspace bash

// reference
https://sharezone47.blogspot.com/2019/05/docker-unable-to-create-ErrorActionPreference.html
# https://sudonull.com/posts/332-Laravel-Docker-Our-Successful-Experience

Rabu, 01 Mei 2019

Docker Unable to create "ErrorActionPreference" (Solved)(Windows)

Come to the New Docker, I get a new error Unable to create: The running command stopped because the preference variable "ErrorActionPreference", and here is the solution (2 solution).
First of all, don't lazy to read the error :
Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The computer 'AKPC-DESKTOP' could not be resolved. Make sure you typed the machine name correctly and that you have network access.
at New-MobyLinuxVM, <No file>: line 218
at <ScriptBlock>, <No file>: line 375
   at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters)
   at Docker.Backend.ContainerEngine.Linux.Start(Settings settings)
   at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass8_0.<Register>b__0(Object[] parameters)
   at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters)
1. If you are seeing "Make sure you typed the machine name correctly and that you have network access"

Solution: you need internet. please turn on your network.

2. After That, Oops we got another error, hahaha. no need to worry.
Unable to execute Start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Failed to create the virtual hard disk.

The system failed to create 'C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx'.
at Ensure-VHD-Path, <No file>: line 306
at New-MobyLinuxVM, <No file>: line 208
at <ScriptBlock>, <No file>: line 411    at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters) in C:\workspaces\stable-18.09.x\src\github.com\docker\pinata\win\src\Docker.Backend\HyperV.cs:line 195
   at Docker.Backend.HyperV.Create(Settings settings) in C:\workspaces\stable-18.09.x\src\github.com\docker\pinata\win\src\Docker.Backend\HyperV.cs:line 125
   at Docker.Backend.ContainerEngine.Linux.Start(Settings settings, String daemonOptions) in C:\workspaces\stable-18.09.x\src\github.com\docker\pinata\win\src\Docker.Backend\ContainerEngine\Linux.cs:line 117
[13:43:17.016][NamedPipeClient][Error  ] Unable to send Start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Failed to create the virtual hard disk.

The system failed to create 'C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx'.
at Ensure-VHD-Path, <No file>: line 306
at New-MobyLinuxVM, <No file>: line 208
at <ScriptBlock>, <No file>: line 411
[13:43:17.016][Notifications  ][Error  ] Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Failed to create the virtual hard disk.

The system failed to create 'C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx'.
at Ensure-VHD-Path, <No file>: line 306
at New-MobyLinuxVM, <No file>: line 208
at <ScriptBlock>, <No file>: line 411

If you are seeing 'Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Failed to create the virtual hard disk.'

Solution :
- open Command Prompt, run as Administrator, then type this one.
MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof

- Then go to this folder : ( in my place The system failed to create 'C:\Users\Public\Documents\Hyper..... so in your side maybe different. ).
C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\....
You will see an administrator prompt there. (i forget what, but Windows will show you a Windows to prompt), just allowed that, so all content there can be seen public.

- Finally, run your docker like usual.

- Case Solved

More info  :
Docker not starting on windows 10 #214
Unable to create: The running command stopped because the preference variable "ErrorActionPreference" #1538
Can't run Docker for Windows after install for the first time #1177

Happy Wednesday
KG




Selasa, 06 November 2018

Wordpress - Debug.log is not working (SOLVED)


Have you guys ever experience this level when your wordpress debug log is not showing correctly @@"

As i go with Wordpress Framework, here what i found

First Write the files debug.log
in path /wp-content/debug.log
Then Check wp-config.php
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
// @ini_set('display_errors',1);
and if debug still not working, try to check in server side :
<?php phpinfo(); ?>
make sure track_errors is ON

if this still not working, then your only choice is move the error.log to shared folder,
Example : This server is old and does not have the latest configuration. By default, you do not have access to the nginx logs.
So moved the logs to share/logs/<yourwebsites>/* 
and also if you have time , take a look at this gist
https://gist.github.com/franz-josef-kaiser/4063197
Bonus : to track php error in your case directly
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

references :
https://wordpress.stackexchange.com/questions/296942/debug-log-file-is-never-created/301298#301298
https://www.elegantthemes.com/blog/tips-tricks/using-the-wordpress-debug-log

Feeling Helped ? Comment below

Sabtu, 03 November 2018

Apa itu .nomedia pada Android


Sering kita temukan file pada beberapa android ada file namanya .nomedia, terutama pada folder thumbnail atau pada folder data di android. tapi apa  kegunaan file ini ?

Apa itu .nomedia ? 

.nomedia atau no media adalah file kosong yang berguna untuk memberitahu sistem kalau folder ini tidak boleh di ditampilkan pada gallery foto, video player, ataupun music player.

Bagaimana Cara membuat file .nomedia ini ? 
untuk gampangnya sih kita tinggal copy/salin saja file .nomedia yang sudah ada pada folder sistem /Android atau pada folder sistem /Data, lalu paste/tempel pada folder yang kita inginkan

Kita juga bisa membuat file ini dengan bantuan notepad editor, seperti ES File Explorer dsb.
kita cukup lakukan penamaan/rename ulang menjadi .nomedia. lalu meletakannya pada folder yang kita inginkan.

~ cukup mudah bukan.


common tags :
.nomedia, cara agar folder tidak terlihat pada gallery foto, video player, ataupun music player, sistem android.

Selasa, 04 Juli 2017

Error Code 10 (This Device Cannot Start) (SOLVED)

Today i am facing this weird issue, my PC suddenly disconnected from the internet.

Case : This Device Cannot Start - Error Code 10

in my testing here i'm using windows 10.



How to solve this issue ? :
  • First , click windows + R , it will open "run.exe" interface, 
  • Then type there : ncpa.cpl 
  • you will get redirected to your network connection.
  • You will see other internet connection that you dont use is being activated and your normal internet connection is shutdown/disable/ removed from there. 
  • Just turn it to disable (other internet connection that you dont use).
  • Next, go to control panel, and search device manager.
  • see your "network adapters" division
  • disable every network that you dont use ( do not uninstall , just disable it ).
  • click your usual network adapter there, and re-enable it. (if it's fail, then restart your PC ).
  • case solved.

    have a nice day. ~KG

    Minggu, 21 Mei 2017

    Sublime text 3 ( laravel artisan not found ) (SOLVED)

      As sublime user facing this laravel issue :
      "Artisan not found"

      that almost scared me to death.

      i'm using sublime text 3, and use laravel version 5,
      tested with laravel 4 too.


    luckly , i solve this one : 

    you can find sublime settings here : ( preferences > Package settings )

    > go to your sublime settings :
    > (choose whether "laravel 4 artisan" or "laravel 5 artisan")
    > select "Settings - default"
    > copy that text (it will be like this)

    {
        "php_path": "php",
        "artisan_path": "artisan"
    }

    >  go to your sublime settings
    > (choose whether "laravel 4 artisan" or "laravel 5 artisan")
    > select "Settings - users"
    > now paste the text here and modify the "php_path" and "artisan_path"

    {
        "php_path": "C:/xampp/php/php.exe",
        "artisan_path": "C:\\xampp\\htdocs\\myfirstapp\\artisan"
    }

    > restart your sublime
    > finish, wish you luck.

    NOTES

    > if you are using my trick you must change "artisan_path" if you use different project.

    ===================
    ===================

    for more info you can see this one : 

    https://github.com/gnarula/sublime-laravelgenerator/issues/30

    Sabtu, 08 April 2017

    Docker login Error / Stuck (SOLVED)(windows)

    Oh no Docker (windows) Stuck at login , why cannot login to my docker through cmd git


    Case :

    Warning: failed to get default registry endpoint from daemon (error during conne ct: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.27/info: open //./pipe/docker_e ngine: The system cannot find the file specified. In the default daemon configur ation on Windows, the docker client must be run elevated to connect. This error
    may also indicate that the docker daemon is not running.). Using system default:  https://index.docker.io/v1/
    Login with your Docker ID to push and pull images from Docker Hub. If you don't
    have a Docker ID, head over to https://hub.docker.com to create one.
    > error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.27/auth: ope n //./pipe/docker_engine: The system cannot find the file specified. In the defa ult daemon configuration on Windows, the docker client must be run elevated to c onnect. This error may also indicate that the docker daemon is not running.
    > docker login
    Error: Cannot perform an interactive login from a non TTY device

    Solution :

    > docker-machine start default
    > docker-machine env default
    > @FOR /f "tokens=*" %i IN ('docker-machine.exe env --shell cmd') DO @%i
    > docker login
    Username: *
    Password: *
    Login Succeeded

    More info  :
    Trying to connect to Docker API for shell commands throws error

    Happy Saturday
    KG

    Jumat, 07 April 2017

    Docker for windows (BASIC guide)

    What is docker ? and why docker ?
    one bad day for dev is that "wait, this work in my machine"

    So, to prevent that we use docker


    Minggu, 02 April 2017

    7 things you must do when using torrent - Utorrent

    7 things you must do when using torrent

    utorrent
    Okay, Who doesnt know this green friendly things in 2017 ??

    Maybe some of you just using it as default, but dont you think that isn't so efficient.




    Today, i will give you 7 trick you must do when using torrent.



    1. Disable the "auto update" from utorrent
      yeah it's so annoying when you open your torrent app and it is installing every single x.x.1 version, (i hope they fix that update system soon and only update when major change not minor).

    2. Distinguish the completed files
      sometimes we are confused how to distinguish completed 100% files from common not 100% complete files. so here we tick "Append .!ut to incomplete files".
    3. Settings the download table
      sometimes we want to know how many percentage the file is and the remaining.
    4. Set your bandwidth priorityyou can set your download priority here , and set the limit of your upload and download.
    5. Shutdown after the download is complete
      not having enough quota and being limited only can download at night ?? no problem, you can try this solution.
    6. Setup your directory
      usually we want to separate the complete torrent from the uncompleted one. you can try to modify this tab menu.
    7. Set limit how many queue for active download
      just modify that maximum number of active download
    Thats all for today, enjoy :3

    Minggu, 05 Februari 2017

    Electronic Charger Tips



    Documentation Files of  Electronic Charger Tips and Issue
    for : handphone, laptop, powerbank, etc.

    Before buying the new one ?  ( skip this step if you’re rich af )
    Go and do some market research.
    -> Search the “model” in google / your fav search engine
    -> Seek for “Price” at your public market (see in amazon, bukalapak, tokopedia, or etc)

    Tips at buying : 
    -> Compare the Charger Ports (if it’s fit or not)
    -> Buy Only The Same Brand of the Charger cause they will works fine.


    Look For its “Output” the Voltage (V) symbol 
    ****(dont buy different voltage charger, or your phone will “boom” for sure).
    example : 19V, then you must buy the exact 19V (no less and no higher)

    See the “Output” Ampere (A)  
    ****(High “A” can make you charge so fast, ).
    example : 6A , then you can buy
    - i suggest you buy the sampe Ampere, or at least lower 10% of Ampere
    - seek more cheaper price ? (MINIMUM) lower 20% of Ampere (MINIMUM), dont dare lower than that, you will get hellish word after take it home.

    How to Maintenance : ( lembiru intensive files )
    -> Always fan/wind your Electronic Charger (cause of heat)
    -> Do not roll around your charger cable by force !!!
    -> Do not put it in your bag after use, fan it a while (cause of heat)(unless is urgent)

    ~ Credits by KG
    base on my experience of charger (not L4D)

    Kamis, 23 Juni 2016

    About CMD.exe / command prompt.exe

    Welcome cmd.exe
    command prompt - aua gelap [sort by command]
    //forget google things
    //just write all XDD


    ============================================================

    [ask / help]
    yourcmdcommad /?

    [bootscreen - default]
    bcdedit /set {default} bootmenupolicy standard
    [bootscreen - advance boot option / black]
    bcdedit /set {default} bootmenupolicy legacy
    [bootscreen - loader only + safe mode]
    Bcdedit /set {bootmgr} displaybootmenu yes

    [exit]
    exit

    [MAC only]
    getmac /v /fo list

    [get IP]
    ipconfig

    [Reset / clear DNS cache]
    ipconfig /flushdns

    example : website is "thetargetedsite"

    [nslookup - find web ip]
    nslookup thetargetedsite[dot]com

    [Ping / call]
    ping thetargetedsite[dot]com
    [Ping / call]
    ping thetargetedsite[dot]com -t
    [pathping - more detail]
    pathping thetargetedsite[dot]com

    [trace route - trace package route]
    tracert thetargetedsite[dot]com

    #
    useful links :
    http://ss64.com/nt/
    http://www.wikihow.com/
    http://en.wikipedia.org/

    Credits by KG

    Minggu, 19 Juni 2016

    NVDIA Driver Crash ??? (Solved)

    Today we talk more about NVDIA,
    You know, most of us doesn't aware about it when our driver get crash and only "intel graphic driver" survived ... ho !!!!!

    This is my experience. having PC formated cause NVDIA driver not working.. ahahaha  too damn lame right >_<

    Now let me share you some of my solution OwwO.



    #1ST Solution

    Reinstall your own Nvdia driver / get your own updatemanually through the NVDIA website

    #2ND Solution

    Reinstall Direct X , 
    you might forget install the most latest Direct X for your System ???  Nope , this not.

    Some of Direct X version might issuing you when installing a game RIGHT !!!!
    as if hahaha. After Restarting your NVDIA get trouble and changed to intel driver survivor ... <(") Wutt.

    Ok for this one am not sure why, but for some apps and games that get different Direct X , might get Crash issue !!!

    Just Download this (Direct X) from my google drive.
    Maybe just version 2005-2007 but this works fine , LOL isnt it @@

    =======================

    PS : remember to restart your PC after each solution.

    =======================

    I might forget another solution, maybe add more in future
    Have a nice Day

    #KG

    Sabtu, 18 Juni 2016

    Speaker is too low / small volume ??? (SOLVED)

    Having your PC Speaker / loudspeaker with full volume, 
    but weak in sound ? too small to be heard by ear ?



    Solution :
    1. go to "Speaker Properties"
    2. you will see 4 tabs there (General,level,Echancement,advanced)
    3. go to "Echancement" tab
    4. Turn ON "Disable all sound Effect"
    5. Enjoy ^^

    OR if you still have too small sound ???
    just reverse it, it works fine  (TESTED) : 
    1. go to "Speaker Properties"
    2. you will see 4 tabs there (General,level,Echancement,advanced)
    3. go to "Echancement" tab
    4. Turn OFF "Disable all sound Effect"
    5. Next is optional :
      Turn ON "Loudness Equalization"
      Turn ON "Virtual Surround"
    6. Enjoy ^^
    Notes : if the sound you hear are broken ? just turn on Loudness Qualization to keep it good. 

    Case : Speaker is too low / small volume ??? (SOLVED)

    Sabtu, 13 Februari 2016

    Host Undetected ???? (SOLVED)

    Experiencing HOST file like undetected from your OS / PC that would be a big issue for some of us.

    HOST file protect us from unwanted program or websites to be accessed from our OS / PC.

    Ok, back to topic,
    now i want to share sometricks about this issue.

    take example i want to block www.facebook.com
    Step#1 - Lets Check first
    1. Open the "cmd" (you can search this)
      or for shortcut : "windows logo" + "R" then type "cmd"
    2. Type "ipconfig /flushdns"
    3. Type "ping www.facebook.com"
    4. You will get 100% lost or  request timeout for that website page. 
    5. if not, try restarting your Modem / internet connection after it.
    Step#2 - Still fail ?
    Take it easy, still more way to rome, >_<
    1. run "cmd" as administrator
    2. type "nbtstat -R"
    3. system reseting the NetBios Cache
    4. test the "ping www.facebook.com"
    Another fail ? (XDDD you might be the worst one)
    Dont Worry Sob, maybe your placing at host files get typography error

    Host files located in C:\windows\system32\drivers\etc\
    go there ok.

    1. edit with notepad / notepad++
    2. at the very bottom
      see ,is there any blocked sites OR comments like this ? "#"
    3. the correct way to type in host is :

              "127.0.0.1 www.facebook.com"
      Format :
      TheWebsiteIP www.thewebsite.com
    4. Save it. (if you fail check please check this out)
    5. Now Check it with the very first step (See "Step#1 - Lets Check First")

    Have a nice day sob. KG 


    #Host #Undetected #SOLVED

    Sabtu, 25 Oktober 2014

    Session 7 and Session 8 - Concurrency

    Ok, pertemuan kali ini adalah pertemuan yang tidak biasa, karena kita akan membahas 2 bab sekaligus >_< sungguh ini bab yg cukup memakan waktu :v

    Pada sesi kali ini kita akan  belajar tentang concurrency.


    Concurrency ?
    concurrency adalah beberapa proses yang berbeda instruksi tetapi berbagi resource yang sama.
    Prosesnya saling berkomunikasi, sharing resource, saling sinkronisasi untuk prosesnya.

    Tujuan Concurrency ?
    - agar bisa terjadi penyampaian informasi untuk 2 proses
    - agar 2 proses  / lebih tidak bertabrakan
    - agar bisa dilakukan sequencing sesuai kebutuhan bila terdapat dependency/ keterbergantungan

    Masalah apa saja tanpa Concurrency ?
    - ketika ada 2 proses yang melakukan read and write pada variable global yang sama, maka tanpa concurrency sangatlah tidak mungkin
    - ketika ada proses yang lebih membutuhkan resource dari proses yang lainnya, bagaimana bisa mensuspendnya sementara agar resource dapat dipakai oleh proses paling membutuhkan.
    - kesalahan saat pengcodingan karena hasil tidak terbatas / non deterministik.

    Race Condition  = kondisi dimana ada 2 proses / lebih yang membaca / write shared data / memory pada saat yang bersamaan. (saling berebut)

    O/S Concern :
    - tracking proses yang aktif
    - alokasi & dealokasi Sumber Daya (waktu processor, memory, File, I/O Device)
    - Proteksi data dan Sumber Daya
    - Hasil Proses harus Independen / tidak bergantung pada kecepatan eksekusi dari concurrency yang lain.

    Critical Region / Section = tempat shared memory diakses.

    Persaingan Antar Resource

    • Mutual Exclusion = sistem yang mencegahan terjadinya 2 proses mengakses Sumber Daya yang sedang dipakai pada waktu yang yang sama. (memakai Critical region).
      • Hanya ada 1 program yang diijinkan saat dalam critical region
      • cth : penggunaan printer untuk printing
    • Deadlock = terjadi karena concurrency
      • cth deadlock :  P1 memakai R1 dan ingin R2 , P2 memakai R2 dan ingin R1 , karena ini P1 dan P2 saling menunggu (deadlock)
    • Starvation = terjadi ketika ada resource yang sangat dibutuhkan 2 proses tetapi 1 proses sangat membutuhkan karena waktu prosesnya terbatas
      • cth starvation : P1,P2,P3 ingin R1
        • P1 selesai memakai R1, lanjut P2 memakai R1
        • ditengah  P1 butuh R1 lagi,
        • Ketika P1 dapat R1, P3 bisa tidak berjalan karena tdk sempat dapat R1
    Kerjasama Antar Proses : 
    • Sharing = write harus mutual exclusive , critical Region dipakai untuk beri integritas.
    • Komunikasi = message dilewatkan, kemungkinan deadlock (karena saling menunggu), kemungkinan starvation (karena dua proses berjalan , yang proses ketiga diabaikan / menunggu message).
    Mutual Exclusion dengan Busy Waiting : (untuk mencapai Mutual Exclusion) 
    1. disabling Interrupt
      • proses berjalan hingga minta layanan OS atau hingga di interrupt
    2. Lock variables
      • variable awal di set ke 0, jika lock = 1 baru boleh masuk ke Critical region
      • masalah yg di alami = Race condition.
    3. Strict alternation
      • untuk strict restriction adalah  sistem swap flag , jadi dia memakai sistem on/off untuk turnnya
      • jadi P1 mendapat turn 0 lalu looping dan mendapat turn 1, lalu ketika P0 meninggalkan critical region di set turn P0 menjadi 1, maka P1 masuk ke Critical Region dan P1 mendapat turn 0 sebelum meninggalkan,
      • dan begitu seterusnya, P1 akan di looping hingga mendapat turn 1 lagi sebelum ke critical region, (begitu pula untuk P0) 
    4. Peterson's solution
      • semua value di set ke 0, P0 set turn = 0 , p0 memasuki critical region.
      • P1 call enter_region untuk masuk ke critical region
      • P1 menunggu interested(0) = FALSE (terjadi bila P0 call leave_region)
        • masalah yg terjadi :
        • klo ada 2 value call enter_region di waktu yg sama, maka yg pertama kali merequest akan tertimpa oleh data yang kedua.
        • kadang proses yang jalan terus, dan ketika sampai di while P0 tidak terjadi looping, tetapi langsung masuk ke critical region, dan P1 harus tetap menunggu.
    5. The TSL instruction
      • butuh H/W yakni register
      • instruksi : TSL,RX,LOCK
    Kelemahan Peterson dan TSL : menggunakan busy waiting, jadi menghabiskan waiting time CPU.


    sleep() = system call yang membuat proses suspended
    wakeup() = system call yang membuat proses ready

    Semaphore = variable khusus yang meiliki nilai integer yang berguna untuk signal
    jika proses wait signal, maka suspended sampai signal sended.
    wait signal dan signal tidak bisa di interrupt.
    diperlukan queue untuk simpan proses yang waiting untuk semaphore.

    • wait signal = -1 semaphore value
    • operation signal = +1 semaphore value
    Semaphore mutex = untuk menjamin 1 proses yang mengakses buffer pada satu waktu dan kevariable lain yang terlibat.

    semaphore full dan empty = untuk sinkronisasi, apa akan terjadi / tidak akan terjadi.



    =======
    Mutex = variable yang bernilai kondisi khusus dari 2 keadaan.
    berguna jika tidak butuh perhitungan semaphore
    cocok dan efisien untuk :

      • mengatur ME pada shared resource
      • paket thread yang diimplementasikan pada user space.
    Mutex_lock = tidak bisa masuk critical region
    Mutex_unlock = bisa masuk critical region

    Mutex dalam pthread :


  • Pthread_cond_init = Kreasi variabel kondisi 


  • Pthread_cond_destroy = Menghapus variabel kondisi 


  • Pthread_cond_wait = Block menunggu untuk signal 


  • Pthread_cond_signal = Signal ke thread lain dan membangunkannya 


  • Pthread_cond_broadcast = Signal multipel thread dan membangunkan semuanya

  • Kelemahan semaphore :

    • operasi down sebelum meletakan item ke buffer
    • bisa terjadi deadlock karena sistem yang berhenti / halt
    • kesalahan kecil bisa berakibat system halt

    Monitor = program yang mengendalikan akses data yang di share
    Kegunaan :

    • proteksi data dari akses nonstruktural
    • mendukung sinkronisasi yang concurrent jadi jaminan mutual exclusion
    • sharing struktur data
    Penerapan ME pada Monitor : 
    • memakai binary semaphore
    • monitor memonitor kondisi Critical region jadi tidak ada 2 proses yang berjalan pada saat yang sama.
    • Monitor menyediakan cara mudah untuk capai ME, (diperlukan block proses)

    Mutual Exclusion pada Monitor :

    • hanya 1 proses yang dieksekusi pada waktu yg sama
    • jika ada yg menerobos masuk maka akan di block
    variable kondisi diberikan kepada monitor (proses wait) sementara.
    • wait(x); //mensuspend hingga proses lain selesai
    • signal(x) // menyelesaikan proses yang disupend

    Perbedaan wait/signal dan sleep/wakeup

    • sleep/wakeup = menidurkan dan mereadykan proses
    Kekurangan Monitor :
    • hanya konsep, harus mengenal banyak bahasa code
    • memaksa aturan ME
    • tidak mengenal semaphore
    • sistem terdistribusi tidak dapat diterapkan
    Kesimpulan
    • Monitor untuk menghindari Race Condition
    • Monitor  = level yang rendah
    Message Passing
    • pakai 2 primitif :
      • send
      • receive
    • primitif = system call dari bahasa pemrograman
    • jika tidak ada message yang tersedia maka receiver akan di block sampai message datang
    • Berguna untuk single dan multi processor dan sistem terdistribusi
    • tidak perlu sharing address
    • penerima dapat memilih receive or block
    • merupakan many to many
    • message dikirm ke area mailbox
    • blocked full jika mailbox penuh
    • ada reply / feedback nahwa message diterima
    • bisa sinkron dan asinkron
    • bisa positif dan negatif
    Mailbox = mekanisme buffer, jika penuh maka message akan ditunda sampai message kosong / dihapus.
    Rendezvous = tidak ada mekanisme buffer, jika send jalan sebelum receive maka send akan di block sampai receive terjadi, jika receive duluan maka akan di block hingga send terjadi.

    Isu mesage passing :
    • Message Lost = hilang , maka sender terpaksa kirim ulang
    • Acknowledgement = mesage diterima, acknowledgement hilang, jadi untuk bedain message yg sama maka diberikan deretan bilangan khusus
    • Domains = memberi nama pada proses saat operasi,harus unik
    • Authentication = cara verifikasi ke server dan enrcrypt message
    • Performance = pengkopian message dari proses ke proses lebih lambat dibanding operasi semaphore, jadi ukuran message dibatasi


    --------------------------------------------------------------------------------------------------------------------------
    1601210682 - Anthony Kalyana
    binus.ac.id
    www.skyconnectiva.com

    Kamis, 16 Oktober 2014

    Session 6 - Process Scheduling

    Sekarang kita akan belajar bagaimana cara thread mengatur prosesnya.

    kita tahu bahwa proses tidak bisa akur, jadi atas dasar tsb, scheduling dibuat.

    Scheduler terjadi didasarkan pada kebijakan / policy, bkn mekanisme.




    ada 4 keputusan pada scheduling : 
    1. switch state running ke waiting (nonpreemptive)
    2. switch state running ke ready(preemptive)
    3. switch state waiting le ready(preemptive)
    4. terminate (nonpreemptive)

    (nonpreemptive) : 
    - proses yang sedang berjalan.running tdk bisa dihentikan, 
    - akan terus berjalan sampai di block atau sampai menyerahkan CPU

    (preemptive) :
    - proses running bisa di hentikan
    - memilih proses untuk dikerjakan dlm kurun waktu tertentu
    - bila melewati batasan waktu maka proses yg berjalan akan di suspend

     Istilah:
    Dispatch latency : waktu yg dipakai dispatcher untuk mensuspend proses dan start proses yang lain untuk running.


    Oke sekarang beranjak ke metode perhitungannya :  >_<

    cth data:

    Proses   Burst Time   Arrived   Priority
    P1          39                0            0
    P2          10                2            3
    P3          3                  1            2
    P4          5                  5            5

    1. FCFS (First Come First Serve)

    • Siapa duluan dia yg masuk
    •  (lihat proses dan burst time) 
    • (JIKA DISOAL HANYA PROSES DAN BURST TIME)
    • jadi Process time : (sebelum ada yg di proses)
    • _P1    P2   P3   P4
    • 0     39    49   52    57
    • kalau waiting time (waiting time for P1): (P1 sudah di proses jadi di taruh di belakang)
    • _P2    P3   P4   P1
    • 0     10    13   18    57
    • (Kalau ada arrived, maka ikutin arrived)
    • jadi Process time : (sebelum ada yg di proses)
    • _P1    P3   P2   P4
    • 0     39    42   52    57


    2. SJFP (preemptive)
    • pertama di lihat arrival timenya, lalu bandingkan burst timenya 
    • (kalau burst time sudah di proses maka kurangi dulu)
    • (dari arrival time dan burst time terkecil)

    • _P1    P3   P2   P4   P2   P1
    • 0       1        4       5       10     19     57
    3. FJNP (Nonpreemptive)

    • pertama di lihat arrival timenya aja
    • klo misal arrival time sama maka bandingin burst timenya
    • nonpreemptive berarti tidak bisa disuspend prosesnya

    • _P1    P3   P2   P4
    • 0      39       42      52    57
    4. Priority
    • (ambil dari priority terbesar)
    • klo priority sama, kerjakan burst time terkecil

    • _P2    P3   P4   P1
    • 0       10      13    18     57
    5. Round Robin
    • dia melingkar , jadi ngurut prosesnya
    • sistemnya sama seperti orang makan di meja bundar dan bergiliran
    • (Tambahan soal   Q=13 sec)
    • Jadi batas proses adalah 13 sec 
    • (JIKA DISOAL HANYA Proses ,Burst time, Priority)
    • _P1    P2   P3   P4   P1   P1
    • 0       13      23    26     31     44     57
    • (Kalau ada arrived, maka ikutin arrived)
    • _P1    P3   P2   P4   P1   P1
    • 0       13      23    26     31     44     57

    FCFS code (hanya logikanya aja):
    //Creator : Anthony Kalyana
    //1601210682
    //Just another uncompiled ones >_<
    #include<stdio.h>
    #include<conio.h>
    int main(){
    char a[10];
    int pt[10],i,j,totalburst=0;
    float avg=0;
    printf("Jumlah proses yang ada:");
    scanf("%d",&j);
    for(i=0;i<j;i++){
    printf("\nProses ke %d name:", i+1);
    scanf("%s”,&a[i]);
    printf("\nMasukan Burst Time :");
    scanf("%d",&pt[i]);
    totalburst = totalburst + pt[i];
    if(i<j-1)
    avg = avg + pt[i];
    }
    printf("\n\n");
    for(i=0;i<j;i++){
    printf("   %s",a[i]);
    }
    printf("\n0   ");
    for(i=0;i<j;i++){
    printf("%d   ",a[i]);
    }
    printf("\n\ntotal burst : %d");
    printf("\naverage : %f",avg/j);
    return 0;
    }
    --------------------------------------------------------------------------------------------------------------------------
    1601210682 - Anthony Kalyana
    binus.ac.id
    www.skyconnectiva.com

    Rabu, 15 Oktober 2014

    Session 5 - Threads

    Masih berkaitan dengan materi pert 4 sebelumnya yaitu process , kali ini kita akan berkenalan dengan thread


    Apa itu thread ? 
    thread adalah entitas yang diatur proses eksekusinya oleh CPU untuk mengatur proses berjalan.
    lebih singkatnya "Process Scheduling"

    Kenapa  thread ?
    - thread memungkinkan user untuk mengeksekusi banyak proses dalam waktu yang pararel pada environment yang sama.
    - lebih mudah untuk create dan delete nya
    - performa > karena proses yang bisa di atur / lebih tertata
    - sangat cocok pada sistem dengan banyak CPU
    - thread dapat saling berkomunikasi tanpa mempengaruhi kernel

    Kelemahan thread? 
    **untuk User space : (tidak ada sangkut paut dgn kernel)
    - blocking system call
    - tidak ada thread yang mampu berjalan ,sampai thread yang sedang di proses di CPU menyerah / drop.
    **untuk Kernel space :
    - cost yang tinggi untuk mencreate dan delete thread

    Istilah :
    Multithreading : memungkinkan 2 atau lebih thread berjalan pada proses yang sama
    register : untuk simpan variable
    stack : history eksekusi
    program counter : pengaturan untuk urutan instruksi 

    Yang di share di thread pada proses yang sama:
    - address space yg sama
    - Instruksi proses
    - open file (descriptor)
    - signal dan signal handler
    - working DIR saat itu
    - user dan group ID

    attribute pada thread :
    - thread ID
    - himpunan register dan stack pointer
    - stack untuk local variale, return address
    - signal mask
    - prioritas
    - return value 

    --------------------------------------------------------------------------------------------------------------------------
    1601210682 - Anthony Kalyana
    binus.ac.id
    www.skyconnectiva.com