Ir ao conteúdo

Exercicio 1 – Sistemas Operacionais II – INE5424 – UFSC

Trabalho 1 – EPOS
Idle-waiting Thread Joining
– Este trabalho tinha como objetivo alterar o modo que era feito o “join” em uma Thread. Sendo que o mesmo inicialmente era feito da seguinte maneira:
[code lang=”c”] while(_state != FINISHING)
yield();
[/code]

O mesmo consiste basicamente, em verificar o estado da thread que se esta dando join e caso o estado nao seja FINISHING dar a vez a outro processo. Esta solucao, acarreta no consumo excessivo de recursos ja que o mesmo sempre retorna para a fila de _ready. E eh executado novamente quando o escalonador escolher esta thread. O trabalho pede que seja modificado de modo que o consumo de recursos nao seja excessivo.

Arquivos Modificados:
thread.cc
Thread.h

Solucao:
     Foi criada uma variável adicional em threads.h, _waiting_for_me, que é um ponteiro para uma thread. Quando o método “join” é chamado, a thread que está executando é colocada no _waiting_for_me da thread chamada e é suspensa. Se a thread já finalizou ou alguém já chamou “join” nela, nada é feito. No método “exit”, caso _waiting_for_me esteja preenchida, é chamado o método “resume” na thread referenciada.
     Pensamos em colocar uma lista de referências para várias threads poderem dar “join” na mesma thread, porém vimos na documentação do POSIX que isso era considerado um erro lógico, e achamos que acarretaria um consumo de recursos adicional desnecessário, pois não seria possível usar o _link já existente na thread, já que ela teria de estar tanto na lista de suspensos quanto na lista _waiting_for_me da outra thread.

Explicacao mais detalhada da implementacao escolhida e outras solucoes pensadas.

2.860 Comentários

  1. flagsync flagsync

    Skipped to a specific section because I knew that was the question I had, and the answer was clean, and a stop at flagsync similarly delivered targeted answers without burying them, content engineered for readers who arrive with specific needs rather than open ended browsing is increasingly valuable in a search heavy reading environment.

  2. creativefashioncorner creativefashioncorner

    Appreciated that the writer trusted the reader to follow along without constant restating of earlier points, and a look at creativefashioncorner continued that respect for the reader, treating an audience as capable adults rather than as people to be hand held through every paragraph is something I notice and value highly across the open internet today.

  3. simplegiftfinder simplegiftfinder

    Good quality through and through, no rough edges and no signs of being rushed, and a quick look at simplegiftfinder kept the same polish going, the kind of site that respects its own brand by maintaining consistency across pages which is something I always appreciate as a reader looking for trustworthy information online today.

  4. yourdailyvalue yourdailyvalue

    Once you start reading carefully here it is hard to go back to lower quality alternatives, and a stop at yourdailyvalue reinforced that ratchet effect, the way good content raises standards is real over time and this site has clearly contributed to raising my expectations for what is possible in writing on the topic generally.

  5. olivepick olivepick

    Took a few notes from this post, the points are easy to remember without needing to come back and check, and a look at olivepick added a couple more, the kind of place that sticks in the memory long after the browser tab has been closed for the day which says a lot really.

  6. sprygain sprygain

    Thanks for the clean writing, no broken sentences and no awkward translations like some other sites have, and a quick stop at sprygain kept that polish going nicely, it really does make a difference when a reader can move through a page without tripping on every line or going back to reread.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *