Trabalho 4/5 – EPOS
Idle Thread
Timing Mechanisms
Nos exercícios 4 e 5 deveríamos criar uma Idle-Thread, a qual deveria somente ser escalonada quando não existirem mais processos prontos para execução. Também tínhamos que eiminar bugs, como o timer handler acordar indesejadamente as threads, e remover o busy-waiting do método delay.
A nova Thread é criada no thread_init.cc, o método passado para ela executar inicialmente é o idle, que foi modificado pra ter um loop, e seu status inicial é WAITING. Para garantir que ela não esteja em nenhuma fila, foram realizadas alterações no método body, para que caso o estado inicial seja WAITING, não acontecer nada. Uma nova variável estática para Thread foi criada, que sempre aponta para a Thread _idle, assim permitindo que qualquer Thread passe a execução para a mesma.
Foi criado um novo método switch_threads(Thread * next), que faz a mudança da thread atual para a thread recebida como parâmetro. Todos os métodos que chamavam a idle() ao perceberem que não possuia ninguém na fila foram alterados para mudar o contexto para a Thread _idle.
O construtor de Alarm foi alterado para receber uma Thread ao invés de uma referência para um método. O método delay foi alterado para suspender a Thread e criar um novo Alarm com uma referência para ela. Assim ela é acordada apenas no tempo programado, elimindando o busy-waiting. Para garantir que ao resumir uma Thread não haveria perdas de informações importantes os resumes são dados somente no final do método timer_handler, mantendo a consistência da fila de Alarms.
O tratador master foi mantido como referência para um método, permitindo que outros tipos de escalonamento sejam definidos. Na definição atual, o mesmo chama o método yield do objeto em execução, caso existam outras Threads prontas para execução ele muda o contexto para a próxima thread. Isto nos gerou outro bug, porque quando a Thread IDLE era executada e chamava o método yield, se já existiam pessoas para continuar a execução ela era inserida na fila de READY, passando a ser tratada como um processo normal. Isso foi corrigido verificando se a thread que estava dando YIELD era a thread _idle, caso fosse, não inseria na lista e não mudava o _state.
Arquivos Modificados:
alarm
thread
alarm
thread_init
thread
pin up yangi bonus https://www.pinup5015.ru
пин ап как зарегистрироваться http://pinup5015.ru
1win ruxsatnoma https://1win5512.ru
мелбет кг http://melbet5001.ru/
melbet клуб баллы [url=melbet5001.ru]melbet5001.ru[/url]
1вин легально в узбекистане https://1win5514.ru/
Visit Back – Your examples really helped me understand better.
как получить демо счет на мелбет как получить демо счет на мелбет
ссылка на мелбет ссылка на мелбет
мостбет кыргызстан скачать http://mostbet2029.help/
мостбет войти в личный кабинет mostbet2029.help
мостбет вход сегодня http://mostbet2031.help/
мостбет скачать на андроид https://mostbet2032.help/
1win chile https://1win3002.mobi/
1win iphone https://1win3002.mobi
bonus 1win https://1win3001.mobi
1win ruxsatnoma http://SPORT-PROGRAMMING.UZ
зеркало 1 win http://1win12047.ru/
My Blog – This taught me more in five minutes than other blogs in an hour.
how to withdraw from 1win how to withdraw from 1win
My name Card – I learned something new today—thanks to this article.
There is certainly a lot to learn about this issue. I love all of the points you’ve made.
I’d like to thank you for the efforts you’ve put in penning this website. I really hope to view the same high-grade content from you in the future as well. In truth, your creative writing abilities has encouraged me to get my own, personal website now 😉
https://t.me/s/officlal_1win/426
сыроедение здоровье и самоисцеление https://rawrussia.ru/ .
сыроедение отзывы https://rawrussia.ru .
внедрение erp 1с 1s-erp-vnedrenie.ru .
внедрение ерп 1с 1s-erp-vnedrenie.ru .
That is a great tip particularly to those new to the blogosphere. Brief but very accurate information… Many thanks for sharing this one. A must read post!
Hey There. I discovered your weblog using msn. This is a really smartly written article. I will make sure to bookmark it and come back to learn more of your helpful information. Thanks for the post. I’ll certainly return.
I always emailed this website post page to all my associates, as if like to read it next my contacts will too.
It’s amazing to pay a visit this web site and reading the views of all colleagues on the topic of this article, while I am also keen of getting know-how.
Hey There. I discovered your weblog the usage of msn. This is a very smartly written article. I’ll make sure to bookmark it and come back to read more of your useful info. Thank you for the post. I will certainly return.
I’ve been exploring for a bit for any high quality articles or blog posts on this kind of house . Exploring in Yahoo I finally stumbled upon this website. Reading this information So i’m satisfied to convey that I have a very excellent uncanny feeling I discovered just what I needed. I such a lot undoubtedly will make certain to do not forget this site and give it a glance on a constant basis.
Keep this going please, great job!
It’s difficult to find knowledgeable people in this particular subject, however, you seem like you know what you’re talking about! Thanks
Wow, marvelous weblog layout! How lengthy have you ever been blogging for? you make blogging look easy. The full glance of your web site is magnificent, let alone the content material