• Like
CTF問題解説 OSのタスク切換え
Upcoming SlideShare
Loading in...5
×

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

  • 1,121 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,121
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 11 8 21
  • 2. 11 8 21
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 11 8 21
  • 15. 11 8 21