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.

4.608 Comentários

  1. Refreshing change from the usual sites covering this topic, no clickbait and no padding, and a stop at byncane confirmed the difference, this place clearly has its own voice rather than copying the formulas everyone else uses to chase clicks online which is becoming increasingly rare these days across nearly every popular subject.

  2. Pass this along to anyone you know dealing with similar questions, the answers here are clear, and a stop at hoxfix adds even more useful material, this is the kind of resource that deserves to circulate widely rather than getting lost in the constant churn of new content online that buries good work daily.

  3. Now recognising that this site has earned a place in the small group of resources I treat as authoritative, and a stop at inaarch confirmed that placement, the difference between resources I trust and resources I just consume is real and this site has clearly moved into the trusted category through consistent quality over time.

  4. A small thank you note from me to the team behind this work, the post earned it, and a stop at mercymodel suggested more thanks would be in order over time, recognising the people who do good writing online is something I try to remember to do because the alternative is silence and silence rewards mediocrity unfortunately.

  5. Honest take is that this was better than I expected when I clicked through, and a look at suppletoast reinforced that, the bar for online content has dropped so much that finding something thoughtful and well constructed feels almost noteworthy now which says more about the average than about this site itself.

  6. My partner and I absolutely love your blog and find
    almost all of your post’s to be exactly I’m looking for.
    Would you offer guest writers to write content available for you?
    I wouldn’t mind publishing a post or elaborating on many of the subjects you
    write about here. Again, awesome web site!

  7. Just want to record that this site is entering my regular reading list, and a look at ibeburn confirmed it deserves the spot, my regular reading list is short and well curated and adding to it requires meeting a fairly high quality bar that this site has clearly cleared without much effort apparently.

  8. Decided to subscribe to the RSS feed if there is one, and a stop at gongketo confirmed that decision, content that I want delivered to me proactively rather than just remembered when I have time is content that has earned a higher level of commitment from me as a reader looking for reliable sources.

Deixe um comentário

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