Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

process.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <gpxe/list.h>
  19. #include <gpxe/process.h>
  20. /** @file
  21. *
  22. * Processes
  23. *
  24. * We implement a trivial form of cooperative multitasking, in which
  25. * all processes share a single stack and address space.
  26. */
  27. /** Process run queue */
  28. static LIST_HEAD ( run_queue );
  29. /**
  30. * Add process to run queue
  31. *
  32. * @v process Process
  33. */
  34. void schedule ( struct process *process ) {
  35. list_add_tail ( &process->list, &run_queue );
  36. }
  37. /**
  38. * Single-step a single process
  39. *
  40. * This removes the first process from the run queue and executes a
  41. * single step of that process.
  42. */
  43. void step ( void ) {
  44. struct process *process;
  45. list_for_each_entry ( process, &run_queue, list ) {
  46. list_del ( &process->list );
  47. process->step ( process );
  48. break;
  49. }
  50. }