커널에서 콘텍스트 스위칭에 대해서 질문있습니다.

dman의 이미지

A 프로세스가 B 프로세스로 전환하려고 할때
A프로세스가 사용하던 레지스터들을 모두 저장하고
B프로세스의 저장한 레지스터값을 다시 세팅해줘야 되는걸로 알고있습니다.

그리고 요즘(2.4부터인가...)에는 이런 코드를 소프트웨어적으로 구현한다고 알고있는데요..
mov를 사용한 코드를 찾지 못하겠네요..
schedule() -> context_switch() ->switch_to()->__switch_to()
이렇게 봤는데 없습니다....

__switch_to 도 mov같은건 없구요......

어디서 찾을수있을까요?
아니면 아직까지 하드웨어에 의존하나요??

574 struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
575 {
576 struct thread_struct *prev = &prev_p->thread,
577 *next = &next_p->thread;
578 int cpu = smp_processor_id();
579 struct tss_struct *tss = &per_cpu(init_tss, cpu);
580
581 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
582
583 __unlazy_fpu(prev_p);
584
585 /*
586 * Reload esp0, LDT and the page table pointer:
587 */
588 load_esp0(tss, next);
589
590 /*
591 * Load the per-thread Thread-Local Storage descriptor.
592 */
593 load_TLS(next, cpu);
594
595 /*
596 * Save away %fs and %gs. No need to save %es and %ds, as
597 * those are always kernel segments while inside the kernel.
598 */
599 asm volatile("movl %%fs,%0":"=m" (*(int *)&prev->fs));
600 asm volatile("movl %%gs,%0":"=m" (*(int *)&prev->gs));
601
602 /*
603 * Restore %fs and %gs if needed.
604 */
605 if (unlikely(prev->fs | prev->gs | next->fs | next->gs)) {
606 loadsegment(fs, next->fs);
607 loadsegment(gs, next->gs);
608 }
609
610 /*
611 * Now maybe reload the debug registers
612 */
613 if (unlikely(next->debugreg[7])) {
614 loaddebug(next, 0);
615 loaddebug(next, 1);
616 loaddebug(next, 2);
617 loaddebug(next, 3);
618 /* no 4 and 5 */
619 loaddebug(next, 6);
620 loaddebug(next, 7);
621 }
622
623 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr))
624 handle_io_bitmap(next, tss);
625
626 return prev_p;
627 }

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.