SlideShare a Scribd company logo
1 of 25
Download to read offline
04/02/20 1
Multitasking
Subject : Processor Architecture & Interfacing
Class : SEIT
Prepared By,
Ms. K. D. Patil, AP
Department of IT, Sanjivani COE, Kopargaon.
04/02/20 2
Multitasking

A task can be a single program or it can be a group of related programs.

A multi-user system also implies multitasking but reverse is not true.

In multitasking operation, 80386 is actually serving only one task/user
for a short time & then moving onto the next task/user & so on.

Each task/user is allotted a time slice (a small fraction of second) .

When the current task/user has used up its time slice, the 80386 saves
all of the current context information & directs towards next task/user.

After serving all tasks/users, 80386 will return to the first task/user ,
pick up where it left off & do as much work as it is able in a time slice.

This technique is known as timesharing.
04/02/20 3
Support Registers and Data
Structures
To provide efficient, protected multitasking, the 80386
employs several special data structures.

The registers and data structures that support
multitasking are:
 Task state segment
 Task state segment descriptor
 Task register
 Task gate descriptor

With these structures the 80386 can rapidly switch
execution from one task to another, saving the context of
the original task so that the task can be restarted later.
04/02/20 4
Task State Segment (TSS)

All the information the processor needs in order to manage a task is
stored in a special type of segment called as task state segment (TSS)

In 80386, a task is any collection of code & data that has a Task State
Segment (TSS) assigned to it.

80386 stores a task’s vital information when the task is not running.

80386 finds all of the information necessary to restart that task when
its turn comes again.

TSS is an area of read/write memory like data segment which is not
accessible to the general user program even at PL0.

The space defined within a TSS is available to 80386 only.

This is it’s private cold storage.
04/02/20 5
Task State
Segment
I/O map base
04/02/20 6
Task State Segment (TSS)

The fields of a TSS belong to two classes:

1. A dynamic set that the processor updates with each
switch from the task. This set includes the fields that
store:
 The general registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI,
EDI). They are stored in the same order in which PUSHAD
instruction would save them onto the stack.
 The segment registers (ES, CS, SS, DS, FS, GS).
 The flags register (EFLAGS). Saving EFLAGS guarantees
that conditional instructions will behave properly when the
task is restarted.
 The instruction pointer (EIP).
 Back Link Field : Keep Track of Task chain. The selector of
the TSS of the previously executing task (updated only when
a return is expected).
04/02/20 7
Task State Segment (TSS)

2. A static set that the processor reads but does
not change. This set includes the fields that
store:
 The selector of the task's LDT.
 The register (PDBR) that contains the base address of the
task's page directory (read only when paging is enabled).
Imply that page Directory can be changed as per Task basis.
 Pointers to the stacks for privilege levels 0-2.
 The T-bit (debug trap bit) which causes the processor to
raise a debug exception when a task switch occurs.
 The I/O map base (I/O permission Bit Map Field) refers to an
additional privilege-related information/function.
04/02/20 8
Task State Segment (TSS)
• I/O permission bit map affects the hardware privilege checking only
for IO instructions like IN, INS, OUT, OUTS, CLI, STI.
• Without I/O permission bit map, a program can execute these I/O
instructions only if CPL is less than or equal to IOPL which is stored in
EFLAGS register.
• When I/O permission bit map is defined for a task, code within that
task has another option to use I/O instructions.
• If the standard I/O permission check fails then 80386 consults the I/O
permission bit map for the particular I/O addresses. If the permission
bit for this I/O address is 0 then the I/O instruction is allowed
otherwise 80386 generates a general protection fault.
04/02/20 9
Task State Segment (TSS)

TSS may reside anywhere in the linear space. The
only case that requires caution is when the TSS spans
a page boundary and the higher-addressed page is
not present. In this case, the processor raises an
exception if it encounters the not-present page while
reading the TSS during a task switch. Such an
exception can be avoided by either of two strategies:
1. By allocating the TSS so that it does not cross a page
boundary.
2. By ensuring that both pages are either both present or both not-
present at the time of a task switch. If both pages are not-present,
then the page-fault handler must make both pages present before
restarting the instruction that caused the task switch.
TSS Descriptor
•
The TSS is defined by a segment descriptor which is
known as TSS descriptor.
•
It appears only in GDT.
04/02/20 10
TSS Descriptor
•
The base address field determines the starting address of
TSS. It must point to physically writable memory. If paging
is enabled in your system, the TSS should be mapped to a
present page of RAM.
•
The limit field determines the size of TSS. As 80386
requires 104 bytes of storage in order to perform a context
save, the limit field must never be less than 00067H. It can
made larger upto 4GB.
•
The DPL field does not imply a privilege level for the TSS
itself. It determines what software can reference the task
defined by this TSS.
04/02/20 11
TSS Descriptor

The B-bit in the type field indicates whether the task is
busy. A type code of 9 indicates a non-busy task; a
type code of 11 indicates a busy task. The B-bit allows
the processor to detect an attempt to switch to a task
that is already busy.

DPL fields of TSS descriptors should be set to zero, so
that only trusted software has the right to perform task
switching.

Other bits are same as data segment descriptor.

The task register (TR) identifies the currently
executing task by pointing to the TSS.
04/02/20 12
Task Register
•
It holds the 16-bit selector. The initial selector must be loaded into TR
which starts the initial task. The selector is changed automatically
whenever the 80386 perform a task switch.
•
TR is used to locate a descriptor in the GDT. The corresponding task
state segment (TSS) descriptor gets automatically read from the global
memory & is loaded into task descriptor cache.
•
This descriptor defines TSS & provides the starting address (BASE)
& the size (LIMIT) of the present segment.
•
Every task has its own TSS which holds the information needed to
initiate the task.
•
TR is always current and self-maintaining. To initialize TR , use the
instruction LTR.
•
On every Task Switch, the processor automatically sets the TS (Task
Switch flag) in register CR0. This bit will never be cleared unless you
do in new Task
04/02/20 13
04/02/20 14
Task Switching
●
A Task Switch can be initiated by software in any of four cases.
●
The current task executes a JMP or CALL that refers to a TSS
descriptor.
●
The current task executes a JMP or CALL that refers to a task gate.
●
An interrupt or exception vectors to a task gate in the IDT. (An
exception or interrupt causes a task switch when it vectors to a task
gate in the IDT. If it vectors to an interrupt or trap gate in the IDT, a
task switch does not occur.)
●
The current task executes an IRET when the NT flag is set.
●
When 80386 performs Task Switch, no information crosses Task
Boundries. Two Tasks are as seperate as they can be and still run on
same processor. This is necessary
●
To keep one Task’s work seperate from another
●
Tasks can be stopped and started at any time without side effects.
04/02/20 15
Task Switching Operation Steps
1. Checking that the current task is allowed to switch to the designated
task. Data-access privilege rules apply in the case of JMP or CALL
instructions. The rule is
MAX (CPL, RPL) < = TSS DPL or Task Gate DPL
2. Checking that the TSS descriptor of the new task is marked present
and has a valid limit. Any errors up to this point occur in the context of
the outgoing task. Errors are restartable and can be handled in a way
that is transparent to applications procedures.
3. Saving the state of the current task. The processor finds the base
address of the current TSS cached in the task register. It copies the
registers into the current TSS (EAX, ECX, EDX, EBX, ESP, EBP, ESI,
EDI, ES, CS, SS, DS, FS, GS, and the flag register). The EIP field of the
TSS points to the instruction after the one that caused the task switch.
04/02/20 16
Task Switching Operation Steps
4. Loading the task register with the selector of the incoming task's TSS
descriptor, marking the incoming task's TSS descriptor as busy, and
setting the TS (task switched) bit of the MSW. The selector is either the
operand of a control transfer instruction or is taken from a task gate.
5. Loading the incoming task's state from its TSS and resuming
execution. The registers loaded are the LDT register; the flag register;
the general registers EIP, EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI;
the segment registers ES, CS, SS, DS, FS, and GS; and PDBR. Any
errors detected in this step occur in the context of the incoming task. To
an exception handler, it appears that the first instruction of the new task
has not yet executed.
04/02/20 17
Task Gate Descriptor
04/02/20 18
Task Gate Descriptor
●
Like Call Gates, Task Gates are special system descriptor.
●
Available in IDT, LDT
●
Task Gate Descriptor does not define a memory segment but instead
acts as an interface point between user code and a TSS.
●
A task gate descriptor provides an indirect, protected reference to a TSS.
●
The SELECTOR field of a task gate must refer to a TSS descriptor.
The value of the RPL in this selector is not used by the processor.
●
When you use selector to a Task Gate in your code, you are indirectly
referencing a TSS descriptor which uniquely identifies a task.
●
The selector to the task gate can be used in place of a selector to a code
segment in FAR JMP and Far CALL instructions.
●
The DPL field of a task gate controls the right to use the descriptor to
cause a task switch. The current program is privileged enough to invoke
the task gate. The Rule is as follows
Max (CPL, RPL) of selector <= Task Gate DPL04/02/20 19
Need of Task Gate Descriptor
●
A procedure that has access to a task gate has the power to cause a task
switch, just as a procedure that has access to a TSS descriptor.
●
The 80386 has task gates in addition to TSS descriptors to satisfy three
needs:
1. The need for a task to have a single busy bit. Because the busy-bit
is stored in the TSS descriptor, each task should have only one such
descriptor. There may, however, be several task gates that select the
single TSS descriptor.
2. The need to provide selective access to tasks. Task gates fulfill this
need, because they can reside in LDTs and can have a DPL that is
different from the TSS descriptor's DPL. A procedure that does not have
sufficient privilege to use the TSS descriptor in the GDT (which usually
has a DPL of 0) can still switch to another task if it has access to a task
gate for that task in its LDT. With task gates, systems software can limit
the right to cause task switches to specific tasks.04/02/20 20
Need of Task Gate Descriptor
3. The need for an interrupt or exception to cause a task switch.
Task gates may also reside in the IDT, making it possible for interrupts
and exceptions to cause task switching. When interrupt or exception
vectors to an IDT entry that contains a task gate, the 80386 switches to
the indicated task. Thus, all tasks in the system can benefit from the
protection afforded by isolation from interrupt tasks.
04/02/20 21
Task Gate Indirectly identifies a task
Task Switching : Direct to TSS
●
Instead of using Task Gate decriptor as an object of an intersegment
Transfer instruction, You can use a selector of the TSS decriptor.
●
The Rule is as follows
MAX (CPL, RPL) < = TSS DPL
●
Depending upon the form you use, 80386 test either TSS Decriptor or
Task Gate task switching is performed.
●
TSS Descriptor is per task and they appear in GDT, all programs or
Tasks have access to it and cause Task Switching assuming they were
privileged enough.
●
If you define Task Gate for that decriptor and locate them in LDTs, you
are restricting Task Switching privileges to only those Tasks with the
gate in their LDTs as well those that run at PL0.
04/02/20 23
Figure : Task
Switching through
TSS
References
● James Turley, “Advanced 80386 programming
Techniques”, Tata McGraw Hill Edition
● http://www.logix.cz/michal/doc/i386/chp07-
00.htm

More Related Content

What's hot

I/O system in intel 80386 microcomputer architecture
I/O system in intel 80386 microcomputer architectureI/O system in intel 80386 microcomputer architecture
I/O system in intel 80386 microcomputer architecturekavitha muneeshwaran
 
8086 in minimum mode
8086 in minimum mode8086 in minimum mode
8086 in minimum modeSridari Iyer
 
INTEL 80386 MICROPROCESSOR
INTEL  80386  MICROPROCESSORINTEL  80386  MICROPROCESSOR
INTEL 80386 MICROPROCESSORAnnies Minu
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationKanchanPatil34
 
Intel® 80386 microprocessor registers
Intel® 80386 microprocessor registersIntel® 80386 microprocessor registers
Intel® 80386 microprocessor registersNeel Shah
 
presentation on timing diagram
presentation on timing diagrampresentation on timing diagram
presentation on timing diagramAlisha Korpal
 
Memory Segmentation of 8086
Memory Segmentation of 8086Memory Segmentation of 8086
Memory Segmentation of 8086Nikhil Kumar
 
Pin Description Of Intel 80386 DX Microprocessor
Pin Description Of Intel 80386 DX MicroprocessorPin Description Of Intel 80386 DX Microprocessor
Pin Description Of Intel 80386 DX MicroprocessorRaunaq Sahni
 
Addressing Modes Of 8086
Addressing Modes Of 8086Addressing Modes Of 8086
Addressing Modes Of 8086Ikhlas Rahman
 
Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kVijay Kumar
 
8086 memory segmentation
8086 memory segmentation8086 memory segmentation
8086 memory segmentationSridari Iyer
 
TM - Techniques
TM - TechniquesTM - Techniques
TM - TechniquesRajendran
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086saurav kumar
 
PAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorKanchanPatil34
 

What's hot (20)

I/O system in intel 80386 microcomputer architecture
I/O system in intel 80386 microcomputer architectureI/O system in intel 80386 microcomputer architecture
I/O system in intel 80386 microcomputer architecture
 
8086 in minimum mode
8086 in minimum mode8086 in minimum mode
8086 in minimum mode
 
INTEL 80386 MICROPROCESSOR
INTEL  80386  MICROPROCESSORINTEL  80386  MICROPROCESSOR
INTEL 80386 MICROPROCESSOR
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
 
Interrupts of microprocessor 8085
Interrupts of microprocessor  8085Interrupts of microprocessor  8085
Interrupts of microprocessor 8085
 
Intel® 80386 microprocessor registers
Intel® 80386 microprocessor registersIntel® 80386 microprocessor registers
Intel® 80386 microprocessor registers
 
8086 Architecture
8086 Architecture8086 Architecture
8086 Architecture
 
presentation on timing diagram
presentation on timing diagrampresentation on timing diagram
presentation on timing diagram
 
Memory Segmentation of 8086
Memory Segmentation of 8086Memory Segmentation of 8086
Memory Segmentation of 8086
 
Pentium processor
Pentium processorPentium processor
Pentium processor
 
Pin Description Of Intel 80386 DX Microprocessor
Pin Description Of Intel 80386 DX MicroprocessorPin Description Of Intel 80386 DX Microprocessor
Pin Description Of Intel 80386 DX Microprocessor
 
Pin diagram 8085
Pin diagram 8085 Pin diagram 8085
Pin diagram 8085
 
Protection 80386
Protection 80386Protection 80386
Protection 80386
 
Addressing Modes Of 8086
Addressing Modes Of 8086Addressing Modes Of 8086
Addressing Modes Of 8086
 
Interrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.kInterrupts on 8086 microprocessor by vijay kumar.k
Interrupts on 8086 microprocessor by vijay kumar.k
 
8086 memory segmentation
8086 memory segmentation8086 memory segmentation
8086 memory segmentation
 
TM - Techniques
TM - TechniquesTM - Techniques
TM - Techniques
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
8086 memory segmentation
8086 memory segmentation8086 memory segmentation
8086 memory segmentation
 
PAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessor
 

Similar to PAI Unit 3 Multitasking in 80386

Pentium Multitasking.ppt
Pentium Multitasking.pptPentium Multitasking.ppt
Pentium Multitasking.pptPramodBorole2
 
Timing n interrupt.pptx
Timing n interrupt.pptxTiming n interrupt.pptx
Timing n interrupt.pptxJasaRChoudhary
 
Assembly programming
Assembly programmingAssembly programming
Assembly programmingOmar Sanchez
 
Design of Real - Time Operating System Using Keil µVision Ide
Design of Real - Time Operating System Using Keil µVision IdeDesign of Real - Time Operating System Using Keil µVision Ide
Design of Real - Time Operating System Using Keil µVision Ideiosrjce
 
8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish Nagar8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish NagarNitish Nagar
 
Project report of ustos
Project report of ustosProject report of ustos
Project report of ustosMurali Mc
 
Microprocessor 8086 and Microcontoller
Microprocessor 8086 and MicrocontollerMicroprocessor 8086 and Microcontoller
Microprocessor 8086 and MicrocontollerSaad Tanvir
 
Microprocessor and microcontroller
Microprocessor and microcontrollerMicroprocessor and microcontroller
Microprocessor and microcontrollerRavinder Singla
 
Microprocessors and microcontrollers
Microprocessors and microcontrollersMicroprocessors and microcontrollers
Microprocessors and microcontrollersgomathy S
 

Similar to PAI Unit 3 Multitasking in 80386 (20)

Pentium Multitasking.ppt
Pentium Multitasking.pptPentium Multitasking.ppt
Pentium Multitasking.ppt
 
Timing n interrupt.pptx
Timing n interrupt.pptxTiming n interrupt.pptx
Timing n interrupt.pptx
 
Micro overview
Micro overviewMicro overview
Micro overview
 
rohini.pdf
rohini.pdfrohini.pdf
rohini.pdf
 
Assembly programming
Assembly programmingAssembly programming
Assembly programming
 
Design of Real - Time Operating System Using Keil µVision Ide
Design of Real - Time Operating System Using Keil µVision IdeDesign of Real - Time Operating System Using Keil µVision Ide
Design of Real - Time Operating System Using Keil µVision Ide
 
8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish Nagar8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish Nagar
 
nasm_final
nasm_finalnasm_final
nasm_final
 
486 or 80486 DX Architecture
486 or 80486 DX Architecture486 or 80486 DX Architecture
486 or 80486 DX Architecture
 
Project report of ustos
Project report of ustosProject report of ustos
Project report of ustos
 
Microprocessor 8086 and Microcontoller
Microprocessor 8086 and MicrocontollerMicroprocessor 8086 and Microcontoller
Microprocessor 8086 and Microcontoller
 
COA_UNIT_I.pptx
COA_UNIT_I.pptxCOA_UNIT_I.pptx
COA_UNIT_I.pptx
 
8086
80868086
8086
 
x86_1.ppt
x86_1.pptx86_1.ppt
x86_1.ppt
 
Microprocessor and microcontroller
Microprocessor and microcontrollerMicroprocessor and microcontroller
Microprocessor and microcontroller
 
EE6502 Microprocessor and Microcontroller
EE6502   Microprocessor and MicrocontrollerEE6502   Microprocessor and Microcontroller
EE6502 Microprocessor and Microcontroller
 
Protection mode
Protection modeProtection mode
Protection mode
 
c++
c++ c++
c++
 
Lect 5
Lect 5Lect 5
Lect 5
 
Microprocessors and microcontrollers
Microprocessors and microcontrollersMicroprocessors and microcontrollers
Microprocessors and microcontrollers
 

More from KanchanPatil34

Unit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfKanchanPatil34
 
Unit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfKanchanPatil34
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfKanchanPatil34
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfKanchanPatil34
 
SE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationKanchanPatil34
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1KanchanPatil34
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1KanchanPatil34
 
SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051KanchanPatil34
 
Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2KanchanPatil34
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1KanchanPatil34
 
Unit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtUnit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtKanchanPatil34
 
Unit 2 se pai_registers in 80386
Unit 2 se pai_registers in 80386Unit 2 se pai_registers in 80386
Unit 2 se pai_registers in 80386KanchanPatil34
 
Unit i se pai_dos function calls
Unit i se pai_dos function callsUnit i se pai_dos function calls
Unit i se pai_dos function callsKanchanPatil34
 
DELD Unit IV ring and twisted ring counter
DELD Unit IV ring and twisted ring counterDELD Unit IV ring and twisted ring counter
DELD Unit IV ring and twisted ring counterKanchanPatil34
 

More from KanchanPatil34 (20)

Unit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdf
 
Unit 2_1 Tree.pdf
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdf
 
Unit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdf
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdf
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
 
SE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentation
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
 
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
 
SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051
 
Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
 
Unit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtUnit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idt
 
Unit 2 se pai_registers in 80386
Unit 2 se pai_registers in 80386Unit 2 se pai_registers in 80386
Unit 2 se pai_registers in 80386
 
Unit i se pai_dos function calls
Unit i se pai_dos function callsUnit i se pai_dos function calls
Unit i se pai_dos function calls
 
DELD Unit V cpld_fpga
DELD Unit V cpld_fpgaDELD Unit V cpld_fpga
DELD Unit V cpld_fpga
 
DELD Unit IV ring and twisted ring counter
DELD Unit IV ring and twisted ring counterDELD Unit IV ring and twisted ring counter
DELD Unit IV ring and twisted ring counter
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 

PAI Unit 3 Multitasking in 80386

  • 1. 04/02/20 1 Multitasking Subject : Processor Architecture & Interfacing Class : SEIT Prepared By, Ms. K. D. Patil, AP Department of IT, Sanjivani COE, Kopargaon.
  • 2. 04/02/20 2 Multitasking  A task can be a single program or it can be a group of related programs.  A multi-user system also implies multitasking but reverse is not true.  In multitasking operation, 80386 is actually serving only one task/user for a short time & then moving onto the next task/user & so on.  Each task/user is allotted a time slice (a small fraction of second) .  When the current task/user has used up its time slice, the 80386 saves all of the current context information & directs towards next task/user.  After serving all tasks/users, 80386 will return to the first task/user , pick up where it left off & do as much work as it is able in a time slice.  This technique is known as timesharing.
  • 3. 04/02/20 3 Support Registers and Data Structures To provide efficient, protected multitasking, the 80386 employs several special data structures.  The registers and data structures that support multitasking are:  Task state segment  Task state segment descriptor  Task register  Task gate descriptor  With these structures the 80386 can rapidly switch execution from one task to another, saving the context of the original task so that the task can be restarted later.
  • 4. 04/02/20 4 Task State Segment (TSS)  All the information the processor needs in order to manage a task is stored in a special type of segment called as task state segment (TSS)  In 80386, a task is any collection of code & data that has a Task State Segment (TSS) assigned to it.  80386 stores a task’s vital information when the task is not running.  80386 finds all of the information necessary to restart that task when its turn comes again.  TSS is an area of read/write memory like data segment which is not accessible to the general user program even at PL0.  The space defined within a TSS is available to 80386 only.  This is it’s private cold storage.
  • 6. 04/02/20 6 Task State Segment (TSS)  The fields of a TSS belong to two classes:  1. A dynamic set that the processor updates with each switch from the task. This set includes the fields that store:  The general registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI). They are stored in the same order in which PUSHAD instruction would save them onto the stack.  The segment registers (ES, CS, SS, DS, FS, GS).  The flags register (EFLAGS). Saving EFLAGS guarantees that conditional instructions will behave properly when the task is restarted.  The instruction pointer (EIP).  Back Link Field : Keep Track of Task chain. The selector of the TSS of the previously executing task (updated only when a return is expected).
  • 7. 04/02/20 7 Task State Segment (TSS)  2. A static set that the processor reads but does not change. This set includes the fields that store:  The selector of the task's LDT.  The register (PDBR) that contains the base address of the task's page directory (read only when paging is enabled). Imply that page Directory can be changed as per Task basis.  Pointers to the stacks for privilege levels 0-2.  The T-bit (debug trap bit) which causes the processor to raise a debug exception when a task switch occurs.  The I/O map base (I/O permission Bit Map Field) refers to an additional privilege-related information/function.
  • 8. 04/02/20 8 Task State Segment (TSS) • I/O permission bit map affects the hardware privilege checking only for IO instructions like IN, INS, OUT, OUTS, CLI, STI. • Without I/O permission bit map, a program can execute these I/O instructions only if CPL is less than or equal to IOPL which is stored in EFLAGS register. • When I/O permission bit map is defined for a task, code within that task has another option to use I/O instructions. • If the standard I/O permission check fails then 80386 consults the I/O permission bit map for the particular I/O addresses. If the permission bit for this I/O address is 0 then the I/O instruction is allowed otherwise 80386 generates a general protection fault.
  • 9. 04/02/20 9 Task State Segment (TSS)  TSS may reside anywhere in the linear space. The only case that requires caution is when the TSS spans a page boundary and the higher-addressed page is not present. In this case, the processor raises an exception if it encounters the not-present page while reading the TSS during a task switch. Such an exception can be avoided by either of two strategies: 1. By allocating the TSS so that it does not cross a page boundary. 2. By ensuring that both pages are either both present or both not- present at the time of a task switch. If both pages are not-present, then the page-fault handler must make both pages present before restarting the instruction that caused the task switch.
  • 10. TSS Descriptor • The TSS is defined by a segment descriptor which is known as TSS descriptor. • It appears only in GDT. 04/02/20 10
  • 11. TSS Descriptor • The base address field determines the starting address of TSS. It must point to physically writable memory. If paging is enabled in your system, the TSS should be mapped to a present page of RAM. • The limit field determines the size of TSS. As 80386 requires 104 bytes of storage in order to perform a context save, the limit field must never be less than 00067H. It can made larger upto 4GB. • The DPL field does not imply a privilege level for the TSS itself. It determines what software can reference the task defined by this TSS. 04/02/20 11
  • 12. TSS Descriptor  The B-bit in the type field indicates whether the task is busy. A type code of 9 indicates a non-busy task; a type code of 11 indicates a busy task. The B-bit allows the processor to detect an attempt to switch to a task that is already busy.  DPL fields of TSS descriptors should be set to zero, so that only trusted software has the right to perform task switching.  Other bits are same as data segment descriptor.  The task register (TR) identifies the currently executing task by pointing to the TSS. 04/02/20 12
  • 13. Task Register • It holds the 16-bit selector. The initial selector must be loaded into TR which starts the initial task. The selector is changed automatically whenever the 80386 perform a task switch. • TR is used to locate a descriptor in the GDT. The corresponding task state segment (TSS) descriptor gets automatically read from the global memory & is loaded into task descriptor cache. • This descriptor defines TSS & provides the starting address (BASE) & the size (LIMIT) of the present segment. • Every task has its own TSS which holds the information needed to initiate the task. • TR is always current and self-maintaining. To initialize TR , use the instruction LTR. • On every Task Switch, the processor automatically sets the TS (Task Switch flag) in register CR0. This bit will never be cleared unless you do in new Task 04/02/20 13
  • 15. Task Switching ● A Task Switch can be initiated by software in any of four cases. ● The current task executes a JMP or CALL that refers to a TSS descriptor. ● The current task executes a JMP or CALL that refers to a task gate. ● An interrupt or exception vectors to a task gate in the IDT. (An exception or interrupt causes a task switch when it vectors to a task gate in the IDT. If it vectors to an interrupt or trap gate in the IDT, a task switch does not occur.) ● The current task executes an IRET when the NT flag is set. ● When 80386 performs Task Switch, no information crosses Task Boundries. Two Tasks are as seperate as they can be and still run on same processor. This is necessary ● To keep one Task’s work seperate from another ● Tasks can be stopped and started at any time without side effects. 04/02/20 15
  • 16. Task Switching Operation Steps 1. Checking that the current task is allowed to switch to the designated task. Data-access privilege rules apply in the case of JMP or CALL instructions. The rule is MAX (CPL, RPL) < = TSS DPL or Task Gate DPL 2. Checking that the TSS descriptor of the new task is marked present and has a valid limit. Any errors up to this point occur in the context of the outgoing task. Errors are restartable and can be handled in a way that is transparent to applications procedures. 3. Saving the state of the current task. The processor finds the base address of the current TSS cached in the task register. It copies the registers into the current TSS (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, ES, CS, SS, DS, FS, GS, and the flag register). The EIP field of the TSS points to the instruction after the one that caused the task switch. 04/02/20 16
  • 17. Task Switching Operation Steps 4. Loading the task register with the selector of the incoming task's TSS descriptor, marking the incoming task's TSS descriptor as busy, and setting the TS (task switched) bit of the MSW. The selector is either the operand of a control transfer instruction or is taken from a task gate. 5. Loading the incoming task's state from its TSS and resuming execution. The registers loaded are the LDT register; the flag register; the general registers EIP, EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI; the segment registers ES, CS, SS, DS, FS, and GS; and PDBR. Any errors detected in this step occur in the context of the incoming task. To an exception handler, it appears that the first instruction of the new task has not yet executed. 04/02/20 17
  • 19. Task Gate Descriptor ● Like Call Gates, Task Gates are special system descriptor. ● Available in IDT, LDT ● Task Gate Descriptor does not define a memory segment but instead acts as an interface point between user code and a TSS. ● A task gate descriptor provides an indirect, protected reference to a TSS. ● The SELECTOR field of a task gate must refer to a TSS descriptor. The value of the RPL in this selector is not used by the processor. ● When you use selector to a Task Gate in your code, you are indirectly referencing a TSS descriptor which uniquely identifies a task. ● The selector to the task gate can be used in place of a selector to a code segment in FAR JMP and Far CALL instructions. ● The DPL field of a task gate controls the right to use the descriptor to cause a task switch. The current program is privileged enough to invoke the task gate. The Rule is as follows Max (CPL, RPL) of selector <= Task Gate DPL04/02/20 19
  • 20. Need of Task Gate Descriptor ● A procedure that has access to a task gate has the power to cause a task switch, just as a procedure that has access to a TSS descriptor. ● The 80386 has task gates in addition to TSS descriptors to satisfy three needs: 1. The need for a task to have a single busy bit. Because the busy-bit is stored in the TSS descriptor, each task should have only one such descriptor. There may, however, be several task gates that select the single TSS descriptor. 2. The need to provide selective access to tasks. Task gates fulfill this need, because they can reside in LDTs and can have a DPL that is different from the TSS descriptor's DPL. A procedure that does not have sufficient privilege to use the TSS descriptor in the GDT (which usually has a DPL of 0) can still switch to another task if it has access to a task gate for that task in its LDT. With task gates, systems software can limit the right to cause task switches to specific tasks.04/02/20 20
  • 21. Need of Task Gate Descriptor 3. The need for an interrupt or exception to cause a task switch. Task gates may also reside in the IDT, making it possible for interrupts and exceptions to cause task switching. When interrupt or exception vectors to an IDT entry that contains a task gate, the 80386 switches to the indicated task. Thus, all tasks in the system can benefit from the protection afforded by isolation from interrupt tasks. 04/02/20 21
  • 22. Task Gate Indirectly identifies a task
  • 23. Task Switching : Direct to TSS ● Instead of using Task Gate decriptor as an object of an intersegment Transfer instruction, You can use a selector of the TSS decriptor. ● The Rule is as follows MAX (CPL, RPL) < = TSS DPL ● Depending upon the form you use, 80386 test either TSS Decriptor or Task Gate task switching is performed. ● TSS Descriptor is per task and they appear in GDT, all programs or Tasks have access to it and cause Task Switching assuming they were privileged enough. ● If you define Task Gate for that decriptor and locate them in LDTs, you are restricting Task Switching privileges to only those Tasks with the gate in their LDTs as well those that run at PL0. 04/02/20 23
  • 24. Figure : Task Switching through TSS
  • 25. References ● James Turley, “Advanced 80386 programming Techniques”, Tata McGraw Hill Edition ● http://www.logix.cz/michal/doc/i386/chp07- 00.htm