Konsep Thread – Sistem Operasi

Thread

Thread merupakan unit dasar dari penggunaan CPU, yang terdiri dari Thread_ID, program counter,register set, dan stack. Sebuah thread berbagi code section, data section, dan sumber daya sistem operasi dengan Thread lain yang dimiliki oleh proses yang sama. Thread juga sering disebut lightweight process. Sebuah proses tradisional atau heavyweight process mempunyai thread tunggal yang berfungsi sebagai pengendali. Perbedaan antara proses dengan thread tunggal dengan proses dengan thread yang banyak adalah proses dengan thread yang banyak dapat mengerjakan lebih dari satu tugas pada satu satuan
waktu.

Banyak sistem operasi modern telah memiliki konsep yang dikembangkan agar memungkinkan sebuah proses untuk memiliki eksekusi multi-threads, agar dapat secara terus menerus mengetik dan menjalankan pemeriksaan ejaan didalam proses yang sama, maka sistem operasi tersebut memungkinkan proses untuk menjalankan lebih dari satu tugas pada satu waktu.

thread

Contohnya sebuah web browser mempunyai thread untuk menampilkan gambar atau tulisan sedangkan thread yang lain berfungsi sebagai penerima data dari network.

Thread Sharing

• Thread menempati ruang alamat memori yang sama
• Tiap thread dapat mengakses data yang sama
• Jika suatu thread mengubah data di memori, maka threadyang lain dapat mengetahuin perubahan data tersebut
• Jika sebuah thread sedang membuka suatu file, maka threadyang lain juga dapat membaca isi file tersebut

Status Thread

  • Spawn :

Otomatis thread terbentuk saat proses terbentuk
Thread bisa dibentuk oleh thread lain dalam satu proses
Thread baru berada pada antrian ready

  • Block :

Thread di block bila menuggu suatu event

  • Unblock :

Bila event yang dibutuhkan sudah datang, maka thread -> ready

  • Finish :

Thread telah selesai dieksekusi

Thread Pools

Pada aplikasi yang multithreading ada 2 masalah yang timbul :

  1. Ukuran waktu yang diperlukan untuk menciptakan thread untuk melayani permintaan yang diajukan terlebih pada kenyataannya thread dibuang ketika ia seketika sesudah ia menyelesaikan tugasnya.
  2. Pembuatan thread yang tidak terbatas jumlahnya dapat menurunkan performa dari sistem.

Solusinya adalah dengan penggunaan thread pools, cara kerjanya adalah dengan membuat beberapa thread pada proses ketika startup dan menempatkan thread-thread tersebut  ke pools, dimana mereka duduk diam dan menunggu untuk bekerja. Jadi ketika aplikasi menerima permintaan maka maka ia akan membangunkan thread dari pool dan jika threadnya tersedia maka permintaan tersebut akan dilayani. Ketika thread sudah selesai mengerjakan tugasnya maka ia kembali ke pool dan menunggu pekerjaan lainnya. Bila tidak thread yang tersedia pada saat dibutuhkan maka aplikasi menunggu sampai ada 1 thread yang bebas.

Keuntungan thread pool :

  1. Bisa lebih cepat untuk melayani permintaan dengan thread yang ada dibanding dengan menunggu thread baru dibuat.
  2. Thread pool membatasi jumlah thread yang ada pada suatu waktu. Hal ini mendukung pada sistem yang tidak bisa mendukung banyak thread

 

Model Multithreading

Dukungan thread disediakan pada tingkat user yaitu user threads dan kernel threads.
User Threads disediakan oleh kernel dan diatur tanpa dukungan kernel, sedangkan kernel therads didukung dan diatur secara langsung oleh sistem operasi.
Hubungan antara user threads dan kernel threads terdiri dari tiga model relasi, yaitu:

Model One to One:

Model One-to-One memetakan setiap thread tingkatan pengguna ke thread kernel.
Ia menyediakan lebih banyak concurrency dibandingkan model Many-to-One.
Keuntungannya sama dengan keuntungan thread kernel.
Kelemahannya model ini ialah setiap pembuatan thread pengguna memerlukan pembuatan thread kernel.
Karena pembuatan thread dapat menurunkan kinerja dari sebuah aplikasi maka implmentasi dari model ini jumlah thread dibatasi oleh sistem.
Contoh sistem operasi yang mendukung model One-to-One ialah Windows NT dan OS/2.

Model One to One

Model Many To One:

Model Many-to-One memetakan beberapa thread tingkatan pengguna ke sebuah thread tingkatan kernel.
Pengaturan thread dilakukan dalam ruang pengguna, sehingga efisien.
Hanya satu thread pengguna yang dapat mengakses thread kernel pada satu saat.
Jadi, multiple thread tidak dapat berjalan secara paralel pada multiprocessor.
Thread tingkat pengguna yang diimplementasi pada sistem operasi yang tidak mendukung thread kernel menggunakan model Many-to-One

Model Many to One

Model Many To Many:

Model ini me-multipleks banyak thread tingkatan pengguna ke thread kernel yang jumlahnya lebih sedikit atau sama dengan tingkatan pengguna thread.
Jumlah thread kernel spesifik untuk sebagian aplikasi atau sebagian mesin.
Many-to-One model mengizinkan developer untuk membuat user thread sebanyak yang ia mau tetapi concurrency (berjalan bersama) tidak dapat diperoleh karena hanya satu thread yang dapat dijadwal oleh kernel pada suatu waktu.
One-to-One menghasilkan concurrency yang lebih tetapi developer harus hati-hati untuk tidak menciptakan terlalu banyak thread dalam suatu aplikasi (dalam beberapa hal, developer hanya dapat membuat thread dalam jumlah yang terbatas).
Model Many-to-Many tidak mengalami kelemahan dari dua model di atas. Developer dapat membuat user thread sebanyak yang diperlukan, dan kernel thread yang bersangkutan dapat bejalan secara paralel pada multiprocessor.
Dan juga ketika suatu thread menjalankan blocking system call maka kernel dapat menjadwalkan thread lain untuk melakukan eksekusi. Contoh sistem operasi yang mendukung model ini adalah Solaris, IRIX, dan Digital UNIX.

many_to_many

Keuntungan Thread

  • Responsif :

Aplikasi yg multithreading dapat meningkatkan respons terhadap user
Sebagai contohnya dalam web browser yang multithreading, sebuah thread dapat melayani permintaan user untuk menampilkan video, sementara thread lain berusaha menampilkan image.

  • Berbagi Sumber Daya :

Thread berbagi memori dan sumber daya dengan thread lain yang dimiliki oleh proses yang sama. Keuntungan dari berbagi kode adalah mengizinkan sebuah aplikasi untuk mempunyai beberapa thread yang berbeda dalam lokasi memori yang sama.

  • Ekonomis :

Dalam pembuatan sebuah proses banyak dibutuhkan pengalokasian memori dan sumber
daya. Alternatifnya adalah dengan penggunaan thread, karena thread berbagi memori dan sumber
daya proses yang memilikinya maka akan lebih ekonomis

  • Utilisasi arsitektur multiprocessor:

Keuntungan dari multithreading dapat sangat meningkat pada
arsitektur multiprocessor, dimana setiap thread dapat berjalan secara pararel di atas processor yang
berbeda.

Referensi :

Stallings,William. 2009. Operating System: Internal and Design Principles.
6th edition. Prentice Hall

Click to access SistemOperasi.pdf

http://mayangadi.blogspot.com/2012/10/konsep-kerja-proses-dan-threads-sistem.html

You may also like...

10 Responses

  1. TerryLom says:

    gay porn, porn, viagra, gambling, private escort, gay dating, scam

    viagra

  2. magdalena says:

    Hello ,
    I’m Magdalena.
    If you’ve ever been too tired and couldn’t finish a research assignment , then you’ve come to the right place. I help students in all areas of the writing technique. I can also write the essay from start to finish.
    My career as an academic writer started early in college . After learning that I was very talented in the field of academic writing, I decided to take it up as a career .

    Professional Academic Writer- Magdalena- http://www.lift-missouri.org Team

  3. marianna says:

    Hi guys, it’s Philip Flowers here!
    I work as an academic writer and have created this content with the intent of changing your life for the better. I started honing my writing abilities in my school years. I learned that my fellow students needed writing help—and they were willing to pay for it. The money was enough to help pay my tuition for my remaining semesters of college.
    Ever since college, I have continued to work as a professional writer. I was hired by a writing service based in the United Kingdom. Since then, the essays that I have created have been sold around Europe and the United States.
    In my line of work, I have become accustomed to hearing, “Philip, can you help me meet my writing assignment deadline?” I know that I can save their time.

    Professional Writer – Philip Flowers – http://www.iranisnottheproblem.orgCorps

  4. henley says:

    Hi guys, my name is Henley Mcfarlane!

    I`m a professional writer and I`m going to change your lifes onсe and for all
    Writing has been my passion for a long time and now I cannot imagine my life without it.
    Most of my works were sold throughout Canada, USA, China and even Australia. Also I`m working with services that help people to save their time.
    People ask me “Mr, Henley, I need your professional help” and I always accept the request, `cause I know, that only I can solve all their problems!

    Professional Writer – Henley – Top 5 Essay Writing Websites For College Students Team

  5. Williamked says:

    Мы можем предоставить любую мотозапчасть в короткий срок прямиком в пункт выдачи автозапчасти редакция – авто сайты автозапчастей.
    Помимо желания предоставить обширный набор автомобильных аксессуаров, наши сотрудники дополнительно выполняем работы над конечным качеством сервиса . В связи с обширным перечнем параметров и вариантов авто каждой марки, мы тут ввели пошаговую схему заказа. Этим образом, мы стремимся не делать закупок и упущений несвоевременных автозапчастей.
    Сделаете заказ у нас запасные части и дополнительно получите скидку на дальнейший заказ!

  6. Zul says:

    mantabbb… jadi tau konsepnya gimana

  7. Cindyron says:

    Spring season cleansing is not only trite to take out dust as well as dirt. However we need to have to conduct an audit of winter clothes. From unneeded traits to get rid of, you need to tidy and identify the storage space. Get rid of the garbage and also give yourself an additional guarantee not to conserve unnecessary scrap. Clean the wall structures as well as roofs, clean the windows, let the spring season in to our home, repel the inactivity.

    Washing in New York City – is actually the regulation of concentrated companies for spring season cleaning of grounds and surrounding areas, as well as maintaining cleanliness. The combination of high quality work and also budget friendly prices is actually a symbolic feature that distinguishes our cleaning firm in the NJ cleaning company market.
    Our motto: ” The most effective high quality – low cost!” as well as you can be certain of that! In our business, quite cost effective prices for all types of cleaning company.
    Our team promise you the arrangement of qualified cleaning company at a high degree. Specialists masterfully learn the procedures of cleansing along with making use of contemporary sophisticated devices and also specialized chemicals. With all this, the rates for our solutions are a lot lower than the major cleaning providers.

    Buying such a service as ” Springtime Cleaning” in our firm, you acquire the opportunity of premium cleansing of the adjacent area of the house. Our team deliver cleaning where others can easily certainly not deal. Our experts are going to come to you even if you go to the additional apocalypse as well as do the cleansing at the highest degree. Only give us a call.

    Find a cleaning service Cobble Hill : spring cleaning

  8. Rickeyzes says:

    Наша компания занимается расскруткой продвижение сайта буржунет совершенно не дорого. В случае, если у вас существует свой бизнес, тогда рано или поздно вы лично осознаете, что без оптимизация и продвижение сайтов сшау вас нет возможности работать дальше. Сейчас фирма, которая подумывают о собственном будущем развитии, должна иметь веб-сайт для seo продвижение сайтов google. продвижение англоязычного сайта в google- способ, используя который возможно приобретать новых покупателей, и дополнительно получить проценты, с тем чтобы рассказать об наличии вашей собственной производственной компании, её продуктах, функциях. Специализированная международная фирма сделать для вашей фирмы инструмент, с помощью которого вы сможете залучать правильных партнеров, получать прибыль и расти.Продающийся сайт- лицо фирмы, в связи с этим имеет значение, кому вы доверяете создание своего веб страницы. Мы – команда профи, которые имеют обширный практический опыт конструирования электронную коммерцию с нуля, направления, разработанного типа. Сотрудники нашей фирмы неизменно действуем по результатом. Международная компания сумеет предоставить всем нашим заказчикам профессиональное сопровождение по доступной антикризисной расценке.Вы можете сделать заказ онлайн-визитку, рекламный сайт. Не сомневайтесь, что ваш портал будет разработан высококлассно, с разными самыми новыми технологиями.

    особенности продвижения сайта google

  9. leticia says:

    Thanks for stopping by my page! I’m Leticia.
    Even though I jokingly credit my aunt for my writing talent, I know that it is a talent I have fostered from childhood. Though my mother is a writer, I also started out young.
    I’ve always had a way with words, according to my favorite professor . I was always so excited in English when we had to do a research writing assignment.
    Now, I help current learners achieve the grades that have always come easily to me. It is my way of giving back to students because I understand the troubles they must overcome to graduate.

    Leticia Figuero – Professional Writer – http://www.learningbenefits.net Corp

  10. eduard says:

    I’m an expert writer who loves to bring smiles to people’s face.

    Writing is what I do for a living and I am so passionate about this. I have worked with several associations whose mission is to help people solve writing problems.
    I love traveling and have visited several places in the past few years.
    I’m happy to have written several books that have contributed positively to the lives of many. My works are available in several parts of the world. And I’m currently working with companies that help people save energy. Being a part of this team has open more opportunities for me to excel as a writer. I have worked with different people and met many clients as a professional.
    I can handle any kind of writing project and provide nothing but the best. People come to me all the time to ask if I can solve their assignment problems and I accept. I find pleasure in helping them to solve their problems as a writer.

    Professional Writer – Eduard – Tips to make remote work effective. Band

Leave a Reply

Your email address will not be published. Required fields are marked *