Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
11   8   21
11   8   21
void main1(int arg)      void main2(int arg)      void main3(int arg)              {                        {             ...
void main1(int arg)      void main2(int arg)      void main3(int arg)              {                        {             ...
void main1(int arg)      void main2(int arg)      void main3(int arg)              {                        {             ...
void main1(int arg)      void main2(int arg)      void main3(int arg)              {                        {             ...
void main1(int arg)      void main2(int arg)      void main3(int arg)              {                        {             ...
void main1(int arg)      void main2(int arg)      void main3(int arg)              {                        {             ...
func_t task_main[] = { main1, main2, main3 };              void schedule()              {                  ...            ...
func_t task_main[] = { main1, main2, main3 };              void schedule()              {                  ...            ...
func_t task_main[] = { main1, main2, main3 };              void schedule()              {                  ...            ...
void task_create()              { ...               static int n = 0;                if (n == TASKNUM)                  sc...
void task_create()              { ...               static int n = 0;                if (n == TASKNUM)                  sc...
11   8   21
11   8   21
Upcoming SlideShare
Loading in …5
×

CTF問題解説 OSのタスク切換え

1,698 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

CTF問題解説 OSのタスク切換え

  1. 1. 11 8 21
  2. 2. 11 8 21
  3. 3. void main1(int arg) void main2(int arg) void main3(int arg) { { { printf("%d", arg); printf("%d", arg); printf("%d", arg); printf("A"); task_change(); printf("G"); task_change(); printf("C"); task_change(); task_change(); task_change(); printf("H"); printf("B"); printf("D"); task_end(); } task_change(); printf("I"); printf("E"); } task_change(); printf("F"); }11 8 21
  4. 4. void main1(int arg) void main2(int arg) void main3(int arg) { { { printf("%d", arg); printf("%d", arg); printf("%d", arg); printf("A"); task_change(); printf("G"); task_change(); printf("C"); task_change(); task_change(); task_change(); printf("H"); printf("B"); printf("D"); task_end(); } task_change(); printf("I"); printf("E"); } task_change(); printf("F"); }11 8 21
  5. 5. void main1(int arg) void main2(int arg) void main3(int arg) { { { printf("%d", arg); printf("%d", arg); printf("%d", arg); printf("A"); task_change(); printf("G"); task_change(); printf("C"); task_change(); task_change(); task_change(); printf("H"); printf("B"); printf("D"); task_end(); } task_change(); printf("I"); printf("E"); } task_change(); printf("F"); }11 8 21
  6. 6. void main1(int arg) void main2(int arg) void main3(int arg) { { { printf("%d", arg); printf("%d", arg); printf("%d", arg); printf("A"); task_change(); printf("G"); task_change(); printf("C"); task_change(); task_change(); task_change(); printf("H"); printf("B"); printf("D"); task_end(); } task_change(); printf("I"); printf("E"); } task_change(); printf("F"); }11 8 21
  7. 7. void main1(int arg) void main2(int arg) void main3(int arg) { { { printf("%d", arg); printf("%d", arg); printf("%d", arg); printf("A"); task_change(); printf("G"); task_change(); printf("C"); task_change(); task_change(); task_change(); printf("H"); printf("B"); printf("D"); task_end(); } task_change(); printf("I"); printf("E"); } task_change(); printf("F"); }11 8 21
  8. 8. void main1(int arg) void main2(int arg) void main3(int arg) { { { printf("%d", arg); printf("%d", arg); printf("%d", arg); printf("A"); task_change(); printf("G"); task_change(); printf("C"); task_change(); task_change(); task_change(); printf("H"); printf("B"); printf("D"); task_end(); } task_change(); printf("I"); printf("E"); } task_change(); printf("F"); }11 8 21
  9. 9. func_t task_main[] = { main1, main2, main3 }; void schedule() { ... for (i = 0; i < TASKNUM; i++) { n = (n + 1) % TASKNUM; current = &task[n]; ...11 8 21
  10. 10. func_t task_main[] = { main1, main2, main3 }; void schedule() { ... for (i = 0; i < TASKNUM; i++) { n = (n + 1) % TASKNUM; current = &task[n]; ...11 8 21
  11. 11. func_t task_main[] = { main1, main2, main3 }; void schedule() { ... for (i = 0; i < TASKNUM; i++) { n = (n + 1) % TASKNUM; current = &task[n]; ...11 8 21
  12. 12. void task_create() { ... static int n = 0; if (n == TASKNUM) schedule(); ... if (setjmp(task[n].context)) task_start(n); n++; task_create();11 8 21
  13. 13. void task_create() { ... static int n = 0; if (n == TASKNUM) schedule(); ... if (setjmp(task[n].context)) task_start(n); n++; task_create();11 8 21
  14. 14. 11 8 21
  15. 15. 11 8 21

×