Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Trabalho referente a materia de Sistemas Operacionais
- // Desenvolvido por : Gabrielle Freitas Rosa
- // Andre
- //
- #include <iostream>
- #include <list>
- using namespace std;
- typedef struct{
- int tam;
- string nome;
- }memo;
- int MAXMEMORY = 0; // O MAX vai controlar ate quanto podemos preencher a lista.Logo, comeca com 0 pois a lista esta vazia;
- list< pair<char, memo> > memory;
- void carregar_programa(memo item){
- if(memory.empty()){
- memory.push_back( make_pair('o', item) );
- MAXMEMORY+ = item.tam;
- }else{
- if(MAXMEMORY < 100){ // se ainda for possivel incluir
- for (list<pair<char, memo> >::iterator it=mylist.begin(); it != mylist.end(); ++it){
- if(memory(it).first == 'l' && memory(it).second >= item.tam){
- memory.push_back( make_pair('o', item) );
- MAXMEMORY+ = item.tam;
- }
- }
- }
- }
- }
- int main(){
- int op, tama;
- bool sair = true;
- string name;
- memo particao;
- while(sair){
- cout << " Nosso sistema de mem贸ria permite" << endl;
- cout << endl;
- cout << " 1 - Carregar um programa na mem贸ria" << endl;
- cout << " -----------------------------------" << endl;
- cout << " 2 - Listar programas carregados na mem贸ria" << endl;
- cout << " -----------------------------------" << endl;
- cout << " 3 - Remover um programa da mem贸ria" << endl;
- cout << " -----------------------------------" << endl;
- cout << " 4 - Mostrar espa莽o total dispon铆vel na mem贸ria " << endl;
- cout << " -----------------------------------" << endl;
- cout << " 5 - Mostrar estado atual da mem贸ria" << endl;
- cout << " -----------------------------------" << endl;
- cout << " 6 - Compactar a mem贸ria" << endl;
- cout << " -----------------------------------" << endl;
- cout << " 7 - Sair" << endl;
- cin >> op;
- switch (op){
- case 1:
- cin >> name >> tama;
- particao.nome = name;
- particao.tam = tama;
- carregar_programa(particao);
- break;
- /*case 2:
- listar_programa();
- break;
- case 3:
- remover_programa();
- break;
- case 4:
- mostrar_espaco();
- break;
- case 5:
- mostrar_memo();
- break;
- case 6:
- compactar();
- break;*/
- case 7:
- sair = false;
- break;
- default:
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement