OSDev

для всех
Текущее время: 28 мар 2024, 15:36

Часовой пояс: UTC + 3 часа




Начать новую тему Ответить на тему  [ 1 сообщение ] 
Автор Сообщение
 Заголовок сообщения: Перестают работать прерывания
СообщениеДобавлено: 25 окт 2012, 17:05 

Зарегистрирован: 17 июн 2012, 09:26
Сообщения: 7
Здраствуйте, на днях столкнулся с проблеммой:
Сначала вроде все работает, задачи переключаются, удаляются итд... Но после определенного количества созданний удаленний задач, при попытке создания новой задачи перестают работать прерывания! Не могу понять в чем дело... Когда создаю ту задачу которая все вешает - форк возвращает id новой задачи в старую, но в новую задачу как показывают тесты даже не заходит (не возвращает 0)...
Вот так выглядит функция fork:
Код:
int fork()
{
   // We are modifying kernel structures, and so cannot be interrupted.
   asm volatile("cli");
   // Take a pointer to this process' task struct for later reference.
   task_t *parent_task = (task_t*)current_task;
   // Clone the address space.
   page_directory_t * directory = clone_directory(current_directory);
   // Create a new process.
   task_t *new_task = CreateTaskStruct ("NULL",GetFreeID(), directory, KERNEL_STACK_SIZE,1,1, last_repaint);

   // Add it to the end of the ready queue.
   // Find the end of the ready queue...
   LinkTask (new_task);
   // This will be the entry point for the new process.
   u32int eip = read_eip();
   // We could be the parent or the child here - check.
   if (current_task == parent_task)
   {
      // This is parent, so set up the esp/ebp/eip for our child.
      u32int esp; asm volatile("mov %%esp, %0" : "=r"(esp));
      u32int ebp; asm volatile("mov %%ebp, %0" : "=r"(ebp));
      new_task->Address.esp = esp;
      new_task->Address.ebp = ebp;
      new_task->Address.eip = eip;
      // All finished: Reenable interrupts.
      asm volatile("sti");
      SaveReturnTaskID (new_task->id);
      // And by convention return the PID of the child.
      return new_task->id;
   }
   else
   {
      // We are the child - by convention return 0.
      return 0;
   }
}


Функция read_eip
Код:
[GLOBAL read_eip]
read_eip:
    pop eax
    jmp eax


Структура задачи такая:
Код:
typedef struct task
{
   struct
   {
      page_directory_t *page_directory;   // Page directory.
   }System;

   struct
   {
      int dynamic;
      int nice;
   }Priority;

   struct
   {
      repaint_type_t repaint;
   }Functions;

   struct
   {
      u32int esp, ebp;         // Stack and base pointers.
      u32int eip;            // Instruction pointer.
      u32int kernel_stack;         // Kernel stack location.
   }Address;
   
   struct
   {
      struct task *parent;         // Parent
      struct task *brother;         // The next task in a linked list.
      struct task *child;         // The back task in a linked list.
   }Link;
   
   char name[256];               //Name process
   enum status_t status;            //Status process
   int id;                  // Process ID.
} task_t;


Есть какие-нибудь мысли, почему такое может происходить? А то я уже голову сломал :?: :evil:


Вернуться к началу
 Профиль  
 
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ 1 сообщение ] 

Часовой пояс: UTC + 3 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Создано на основе phpBB® Forum Software © phpBB Group
Русская поддержка phpBB