CN101556545B - Method for realizing process support, device and multithreading system - Google Patents

Method for realizing process support, device and multithreading system Download PDF

Info

Publication number
CN101556545B
CN101556545B CN2009100843590A CN200910084359A CN101556545B CN 101556545 B CN101556545 B CN 101556545B CN 2009100843590 A CN2009100843590 A CN 2009100843590A CN 200910084359 A CN200910084359 A CN 200910084359A CN 101556545 B CN101556545 B CN 101556545B
Authority
CN
China
Prior art keywords
thread
agent thread
module
resource
scheduler
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN2009100843590A
Other languages
Chinese (zh)
Other versions
CN101556545A (en
Inventor
丁兆杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Star Net Ruijie Networks Co Ltd
Original Assignee
Beijing Star Net Ruijie Networks Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Star Net Ruijie Networks Co Ltd filed Critical Beijing Star Net Ruijie Networks Co Ltd
Priority to CN2009100843590A priority Critical patent/CN101556545B/en
Publication of CN101556545A publication Critical patent/CN101556545A/en
Application granted granted Critical
Publication of CN101556545B publication Critical patent/CN101556545B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method for realizing process support, a device and a multithreading system. The method comprises the following steps of: establishing process; establishing an agent thread corresponding to the process; and when the agent thread obtains processor resource allocated by a scheduler, allocating the processor resource to the process corresponding to the agent thread. The methodcan effectively realize the support to the process under the condition that any modification is not needed to the operating system of the original multithreading system and all the software modules.

Description

Method, device and multi-threaded system that a kind of implementation process is supported
Technical field
The present invention relates to method, device and multi-threaded system that a kind of implementation process is supported, belong to data communication technology field.
Background technology
Embedded system is a kind of controlled device inside that embeds fully, the special purpose computer system that designs for application-specific.This system mainly is applicable to the application that function, reliability, cost, volume, power consumption is had strict demand.
Along with the development of embedded system, the complexity of embedded software is more and more higher, has therefore introduced embedded OS in embedded systemic software development.Embedded OS is a kind of support embedded system applied operating system software, can effectively manage the system resource that becomes increasingly complex, provide the multitask running environment to plug in software module, make program development be more prone to, be convenient to safeguard, can improve the stability and the reliability of system simultaneously.
In most of embedded OS, multitask is to realize with the form of multithreading.The representative products of this type operating system is real-time multi-task operating system Nucleus PLUS, real time operating system VxWorks, hard real-time operating system ThreadX and real-time multiprocessing system RTEMS etc. at present.In this type operating system, " task (Task) " and " thread (Thread) " is same notion.From the angle of this type systematic, thread is the minimum run unit of compete for system resources.Thread can use or wait for system resources such as central processing unit (Central Process Unit is called for short CPU), I/O (Input/Output is called for short I/O) equipment and internal memory, and is independent of other threads, with they concurrent runnings.We claim that this type operating system is the multithreading operation system.
In the multithreading operation system, the part of most critical is exactly thread scheduler (Scheduler).Thread scheduler is distributed to suitable thread according to certain scheduling strategy with processor resource, and the thread that has obtained processor resource just is called this thread and " management and running ".Modal in embedded OS is to adopt the mixed scheduling strategy that is aided with Time Slice Circular Scheduling between the same priority based on the preemption scheduling of priority, i.e. multipriority robin scheduling.Under this scheduling strategy, thread is determined two the crucial scheduling parameter of oneself according to its function and performance requirement: priority and timeslice.The thread that is ready to move just becomes the thread of " ready ", and scheduler comes all ready threads the medium processor resource to be allocated of scheduling waiting list of different priorities according to the height of priority.Thread with high priority can preferentially obtain processor resource, and the timeslice of thread has then determined a thread to obtain the time that can use processor behind the processor resource.In case the timeslice of thread uses up, scheduler will be deprived the processor resource of this thread, and the afterbody that this thread is discharged to corresponding priority query is again requeued, the scheduling strategy of Here it is between peer round-robin.
In embedded system, hardware device (as network interface, temperature sensor etc.) can occur in the incident in the hardware device with the form request software processes of electronic signal.This electronic signal just is called as " interruption ".When processor receive when interrupting will be temporarily out of service current using the thread of processor and changing in the interrupt service routine that operating system provides carry out the interrupt response processing, this just is called this thread and is interrupted and has interrupted.Being interrupted the thread that interrupts before in most of the cases operating system can be returned processor resource after finishing the interrupt response processing recovers to carry out.But in the interrupt response processing procedure, system may allow the thread with higher priority be ready to operation in some cases, and adds the scheduling waiting list.At this moment scheduler finish processor resource will be distributed to after interrupt response is handled this new ready higher priority thread rather than before the thread that interrupted.This just is called the processor resource that high priority thread has been seized low priority thread, and this scheduling strategy is exactly the preemption scheduling strategy.
Operating system is used a kind of data structure that is called as thread control block (Thread Control Block) or task control block (TCB) (Task Control Block) to follow the tracks of and is safeguarded the information relevant with certain thread, comprises storehouse, scheduling parameter, running status and the code etc. of thread.Operating system can be suspended the thread operation when each thread was deprived processor resource, and the running state information of thread is kept in the thread control block directly or indirectly.Operating system will be taken out the status information of preserving last time when redistributed processor resource to this thread next time from the thread control block of this thread, and the state that this thread is returned to before suspending continues normal operation.
Along with the development of embedded system, the function of embedded system from strength to strength, software systems also become increasingly complex, reliability requirement is also more and more higher.Usually have the software code of high complexity and comparatively harsh reliability requirement as embedded systems such as network communication equipments.But threads all in the multithreading operation system all move in same resource space, that is: all threads use the shared system resources such as memory source, file resource and device resource of the overall situation jointly.As long as any one thread breaks down and all may cause global resource destroyed, cause the total system collapse.Therefore for the needs of fault isolation and high reliability, more and more this class complex embedded system need be introduced the deficiency that the process of using usually originally remedies the multithreading operation system in PC or mainframe computer.
Process is exactly that process has oneself independently resource space with respect to its major different of thread.For example: each process all has memory headroom and the file resource space etc. of oneself, and process can only be operated one's own resource.If therefore fault has taken place process, fault just is isolated in the resource space of process oneself by strictness, and can not involve other software modules of other processes and system.Operating system only need be killed crashed process and discharge all resources that this process occupies and can be fixed a breakdown, and the fault of a process can't cause the collapse of total system.So the process of employing technology helps improving the reliability of embedded system, some newer embedded OSs also begin to support the multi-process technology at present, as real-time operating system QNX and some embedded Linux systems etc.
In multi-process operating system, the multiprocess scheduling device that scheduler is normally special can only dispatching process.And thread participates in scheduling as a kind of special process, is exactly a kind of special " Lightweight Process " as thread among the Linux.With the multithreading operation system class seemingly, multi-process operating system is also used a kind of data structure that is called process control block (PCB) (Process Control Block) to follow the tracks of and is safeguarded the information relevant with certain process.The content that process control block (PCB) comprised also comprises independently resource space information of process except storehouse, scheduling parameter, running status and the code of process.Mainly comprise process file space, memory headroom and the device space etc. in the resource space of process, wherein the most important thing is the memory headroom of process.Required code (Code), dynamic heap (Heap) and user stack critical datas such as (Stack) all must be positioned at the memory headroom of process during the process operation.When process switching taking place, the resource space that the process scheduling device must switch to the process of preparing management and running earlier removes the process code that could recover this running state of a process then and bring into operation and be arranged in the proceeding internal memory space at every turn.
Usually for newly-designed embedded system, we can select suitable multi-process operating system to carry out software development according to real needs.Yet in actual conditions, we usually will transform an original embedded system, make it to possess the process tenability so that adapt to current new high reliability request, prolong the lifetime of this class original system.For original embedded system based on the multithreading operation system, industry generally takes two kinds of technical schemes to make it the support process.A kind of technical scheme is to be multi-process operating system with original multithreading operation system conversion, then other software modules are reconstructed, that is: under the situation that does not change former software module function, software module is developed again and encoded, enable on new multi-process operating system, to move.Another kind of technical scheme is the multithreading operation system of revising in the original system, transform it as multi-process operating system.Simultaneously other software modules are revised, enabled to adapt to transformed operating system.
The problem of first kind of prior art scheme is that for embedded system software module is often combined closely with embedded OS.Usually change embedded OS and just meaned the scheduling behavior of total system, application programming interface (the Application ProgrammingInterface of operating system, being called for short API) variation completely all taken place in (being one group of function interface that operating system externally provides, the various functions that other software modules can use operating system to provide by this group interface) and various system service (as communication between break in service, device drives, process/thread, file system etc.).Big often having to of this variation solves by the approach of thorough rewriting related software module.Yet for some complicated embedded system (as the network service type systematic), its software may be made of millions of line codes, needs several technician just can finish through development﹠ testing for many years.Even it also is a very white elephant concerning large enterprise that these codes are rewritten spent human and material resources, financial resources and time completely, general medium and small sized enterprises can't bear at all.
Then there are two subject matters in second kind of prior art scheme.First problem is for the nonopen commercial embedded OS of some source code, owing to there is not the operating system source code, has no idea it is made amendment at all, can't implement this technical scheme.Another problem is promptly to allow to the origin operation system is made amendment, even and can keep main mechanism such as the api interface of origin operation system and system service not change in modification process as far as possible.But because amended operating system will be become the cause of multi-process environment by multi-thread environment to the running environment that software module presents, the part relevant with thread also must be carried out corresponding modification then the support process in all original software modules, to adapt to new multi-process running environment.Yet developed and used original system for a long time for some, because it is in large scale, the construction cycle is long, and be in all the time after it drops into application in the middle of the long-term and continual maintenance process, software code is constantly introduced new modification.May be in so very long process because developer's change of personnel, or, cause the code of a large amount of original systems to be understood fully by current software developer owing to when developing and safeguarding original system, do not use the modern software engineering method to manage causes such as causing the document deficiency.The risk that original software code is made amendment is very big in this case, may introduce more software fault in modification process, reduces the quality of software and the reliability of system.
Summary of the invention
The purpose of this invention is to provide method, device and multi-threaded system that a kind of implementation process is supported, can not need effective support that realizes process under the situation that operating system and each software module of original multi-threaded system are made any modification.
For achieving the above object, the invention provides a kind of method that implementation process is supported in multi-threaded system, described method comprises:
The establishment process;
Create the agent thread of described process correspondence; Described agent thread is dispatched by scheduler and is realized replacing its corresponding process to line up in the scheduling queue of scheduler;
Obtain the processor resource of described scheduler distribution when described agent thread after, described processor resource is transferred the process of described agent thread correspondence.
To achieve these goals, the present invention also provides a kind of device that implementation process is supported in multi-threaded system, and described device comprises creation module, process module, agent thread module and resource distribution module;
Described creation module is used for the establishment process, and the agent thread of described process correspondence; Described agent thread is dispatched by scheduler and is realized replacing its corresponding process to line up in the scheduling queue of scheduler;
Described process module is connected with creation module, is used for the maintenance process relevant information;
Described agent thread module is connected with creation module, is used for maintenance proxy thread relevant information;
Described resource distribution module is connected with creation module, process module and agent thread module, is used for described processor resource being transferred the process of described agent thread correspondence after described agent thread obtains the processor resource of scheduler distribution.
To achieve these goals, the multi-threaded system that the present invention provides a kind of implementation process to support again comprises said apparatus, also comprises Scheduler module and original break in service module;
Described Scheduler module is used to carry out the scheduling and the processor resource distribution of agent thread;
Described original break in service module is used to carry out the thread interrupt response.
The present invention distributes to the process of described agent thread correspondence by agent thread with the processor resource that obtains, and has realized realizing in original multi-threaded system the support to process.The scheduler of original multi-threaded system still only needs to be responsible for multithread scheduling and does not need to carry out any modification, and system Central Plains has the scheduling behavior of thread that any variation can not take place yet, thereby changes very little to original multi-threaded system.
Description of drawings
Fig. 1 is a kind of method embodiment one synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 2 is a kind of method embodiment two synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 3 is a kind of method embodiment three synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 4 is a kind of method embodiment four synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 5 is a kind of method embodiment five synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 6 is a kind of device embodiment one synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 7 is a kind of device embodiment two synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 8 is a kind of device embodiment three synoptic diagram that implementation process is supported in multi-threaded system of the present invention
Fig. 9 is a kind of device embodiment four synoptic diagram that implementation process is supported in multi-threaded system of the present invention
The multi-threaded system embodiment synoptic diagram that Figure 10 supports for a kind of implementation process of the present invention
Embodiment
The invention provides method, device and multi-threaded system that a kind of implementation process is supported, can not need effective support that realizes process under the situation that operating system and each software module of original multi-threaded system are made any modification.The present invention will be described in detail below in conjunction with accompanying drawing.
Fig. 1 has provided a kind of method embodiment one synoptic diagram that implementation process is supported in multi-threaded system of the present invention, said method comprising the steps of:
Step S1, the establishment process;
Step S2 creates the agent thread of described process correspondence;
Agent thread can be the thread that a class has specific function, and it can help corresponding process to wait in line the right to use of processor in the scheduling queue of scheduler, and is obtaining after the processor right to use it being transferred corresponding process.
Step S3 behind the processor resource that described agent thread acquisition scheduler distributes, transfers described processor resource the process of described agent thread correspondence.
From the viewpoint of measures of original system scheduler, other threads in agent thread and the system there is no any difference.Therefore scheduler is its distribution processor resource according to the identical strategy of other threads of scheduling agent thread being dispatched.As long as agent thread is arranged in the scheduling queue of scheduler, scheduler is always being chosen this agent thread sometime and processor resource is being distributed to it.By agent thread the processor resource that obtains is distributed to the process of described agent thread correspondence, realized in original multi-threaded system, realizing support process.The scheduler of original multi-threaded system still only needs to be responsible for multithread scheduling and does not need to carry out any modification, and system Central Plains has the scheduling behavior of thread that any variation can not take place yet, thereby changes very little to original multi-threaded system.
Fig. 2 has provided a kind of method embodiment two synoptic diagram that implementation process is supported in multi-threaded system of the present invention, present embodiment is except the step that comprises method embodiment one, and the process of among the step S3 described processor resource being distributed to described agent thread correspondence specifically also comprises:
Step S31 searches the process of described agent thread correspondence;
Step S32 switches to the process resource space of described process; Specifically can from the process control block (PCB) of process, obtain the process relevant information, thereby switch to the process resource space of described process.
When switching, agent thread should use certain process resource to isolate handoff technique, as: the isolation and the switching of technology implementation process resource spaces such as proceeding internal memory page table, process file table.
Step S33 recovers described running state of a process; Specifically can from the process control block (PCB) of process, obtain the process relevant information, thus the running status of recovering process.
Step S34 carries out the code of described process.
By above-mentioned steps as seen, agent thread distribution processor resource gives corresponding process not by scheduler, so scheduler can't be known the existence of process, has realized that process is to the shielding of original system scheduler in the scheduling process.
Fig. 3 has provided a kind of method embodiment three synoptic diagram that implementation process is supported in multi-threaded system of the present invention, and present embodiment also comprises except the step that comprises method embodiment one:
Step S41 is receiving when interrupting, and what check current operation is process or thread, if thread execution in step S44 then, if process execution in step S42 then;
The current operation of described inspection be that process or thread specifically can be judged according to following method: check the interrupt return address that processor is preserved when interrupting arriving, the address of this address instruction that to be exactly processor carrying out in the moment of interrupting producing, if this address is positioned at outside the proceeding internal memory spatial dimension of process, then think current interrupted be thread, the proceeding internal memory space can produce when the process of establishment, also can in the process that process is carried out, produce as required, specifically isolate handoff technique by process resource, as: the proceeding internal memory page table, the distribution of technology implementation process memory headrooms such as process file table, isolate and switching.
Step S42 is saved in the running status of current process in the process control block (PCB) of described process;
Step S43, the processor resource that process is used transfers the agent thread of described process correspondence;
Step S44, the interrupt service routine of execution multi-threaded system.
By above-mentioned steps as seen, the present invention can return agent thread with processor resource from process earlier before entering the interrupt service routine of original system.Therefore the interrupt service routine of original system also can't be known the existence of process, thinks that still what interrupted by current interruption is agent thread.So the interrupt service routine of original system does not need to carry out any modification yet.
Present embodiment can also carry out above-mentioned expansion except carrying out the above-mentioned expansion on the basis of method embodiment two on the basis of method embodiment one.
Fig. 4 has provided a kind of method embodiment four synoptic diagram that implementation process is supported in multi-threaded system of the present invention, and present embodiment also comprises except the step that comprises method embodiment three:
Step S51 after the order that receives the process of killing, searches the agent thread of described process correspondence;
Step S52 stops described agent thread;
Step S53 deletes described agent thread;
Step S54 deletes the information relevant with described process;
Specifically in the process of establishment, can generate process list storage process relevant information, need the relevant entries in the deletion process tabulation during deletion process.
Step S55 discharges the resource that described process takies.
Present embodiment can also carry out above-mentioned expansion except carrying out the above-mentioned expansion on the basis of method embodiment one or method embodiment two on the basis of method embodiment three.
Fig. 5 has provided a kind of method embodiment five synoptic diagram that implementation process is supported in multi-threaded system of the present invention, and present embodiment also comprises except the step that comprises method embodiment two:
Also comprise step S11 after the described step S1: described course allocation process is numbered, and in process list, write down the corresponding relation of described process and process numbering;
System can put into process a process list after the establishment process, and each process is numbered, and process is in case establishment just is endowed a unique numbering, and system can find corresponding process by this numbering.In this process whole life, promptly process from be created to extinction during this period of time in, this numbering can not change all the time, we claim this to be numbered process numbering (Process ID is called for short PID).
Also comprise step S21 after the described step S2: described agent thread writes down the process numbering of described process;
Described step S31 is specially: the process of searching described agent thread correspondence according to the process numbering.
Each agent thread is all writing down the PID of its process of serving.After scheduler is distributed to certain agent thread with processor resource, this agent thread just can be searched corresponding process at process list according to the PID of process, processor resource with oneself transfers this process then, and this process obtains the processor right to use and brings into operation.
Present embodiment can also carry out above-mentioned expansion except carrying out the above-mentioned expansion on the basis of method embodiment three or method embodiment four on the basis of method embodiment two.
Core concept of the present invention is: participate in schedule activities by the mode of creating agent thread by thread replacement process, make the scheduler of original system still only need to be responsible for multithread scheduling, thereby do not need scheduler is carried out any modification.Because scheduler does not change, and system Central Plains has the scheduling behavior of thread also any change can not take place, original software module is still moved under multi-thread environment simultaneously.Therefore each software module does not need to make any modification because of the introducing of process yet in the original system.So just reached the purpose that implementation process is supported under the prerequisite of not changing original system, minimum to the original system influence.
System can put into all establishment processes a process list, and each process is numbered.Process is in case create and just to be endowed a unique number, and this numbering is similar to the identification card number of people in the actual life, can process of unique identification, and system can find corresponding process by this numbering.In this process whole life, promptly process from be created to extinction during this period of time in, this numbering can not change all the time, we claim this process that is numbered process numbering PID.
Respectively create the scheduling broker of a thread as this process for each process in system, we claim that this thread is the agent thread of process.Agent thread is the thread that a class has specific function, and it can help corresponding process to wait in line the right to use of processor in the scheduling queue of scheduler, and is obtaining after the processor right to use it being transferred corresponding process.The scheduling parameter of agent thread must be identical with corresponding process, and for example both dispatching priorities must be identical with timeslice.
From the viewpoint of measures of original system scheduler, other threads in agent thread and the system there is no any difference.Therefore scheduler is according to the identical strategy of other threads of scheduling agent thread being scheduling to its distribution processor right to use.As long as agent thread is arranged in the scheduling queue of scheduler, scheduler is always being chosen this agent thread sometime and processor resource is being distributed to it.
Each agent thread is all writing down the PID of its process of serving.After scheduler is distributed to certain agent thread with processor resource, this agent thread will lookup process tabulation, just find after the pairing process of PID processor resource to transfer this process with oneself.Then this process obtains the processor right to use and brings into operation.
Agent thread adopts step S31 as described in Figure 2 oneself processor resource to be transferred process to step S34.When step S32 carried out the switching of process resource space, agent thread can use certain process resource to isolate handoff technique, as: the isolation and the switching of technology implementation process resource spaces such as proceeding internal memory page table, process file table.
This shows that this processor right to use transfer carries out fully, does not pass through scheduler between agent thread and corresponding process.So scheduler can't be known the existence of process, realized that process is to the shielding of original system scheduler in the scheduling process.
In embedded OS, when each interruption arrived, scheduler all can be forced to regain processor resource so that carry out Interrupt Process and the processor resource reallocation, and promptly scheduler may be reselected the thread scheduling operation of limit priority.Therefore need before regaining processor resource, scheduler return corresponding agent thread to processor resource from process earlier.This processing must be carried out in interrupt service routine, and its processing procedure is: processor goes jumping to a specific instruction address automatically when receiving the interruption of being sent by hardware device or timer.The code that is positioned at this instruction address just is called interrupt service routine.
New act on behalf of the interrupt service routine that interrupt service routine is replaced original system by one among the present invention, act on behalf of interrupt service routine and will do following processing:
Step 101 checks that current to be interrupted what interrupt be process or thread.If thread then jumps to step 104, otherwise execution in step 102;
Step 102 is saved in the process control block (PCB) of this process this process so that next agent thread can be resumed operation again with the running status of current process;
Step 103 is distributed to the pairing agent thread of current process with processor resource;
Step 104 jumps to the interrupt service routine of original system, continues the interrupt response process, and this interrupt service routine can be transferred to scheduler again with processor resource usually.
As seen, the interrupt service routine of acting on behalf of of the present invention had been returned agent thread with processor resource from process earlier before entering the interrupt service routine of original system.Therefore the interrupt service routine of original system also can't be known the existence of process, thinks that still what interrupted by current interruption is agent thread.So the interrupt service routine of original system does not need to carry out any modification yet.
From top description as can be known, the present invention fully outside the scheduler of original system and interrupt service routine expansion realized the process support.Concerning other parts of original system, process is sightless, and the scheduling behavior of original system is also without any variation.Each software module in the original system and operating system all need not to make any modification, only need realize that a process support module can expand the support to process on the basis of old system, can support the new application software module of developing based on process according to scheme described in the present invention.
The present invention uses agent thread replacement process to participate in schedule activities in the old system.Because the existence of agent thread, process shields invisible fully to original system, and the original part in the original system does not need to do any revision, makes that the invention process amount of getting up to work is little, risk is low, thereby easy to implement.And, do not need to be concerned about the scheduling strategy of original system during the invention process because the schedule activities of agent thread is still implemented by the scheduler of original system yet, and therefore going for any embedded multithreading operation system, versatility is good.
Be responsible for the processor resource of its acquisition is transferred process by agent thread, the processor resource of implementation process distributes, from the angle of process, process also perception less than the existence of agent thread.Therefore the present invention has shielded the thread scheduling details of original system to process, presents to the traditional multi-process running environment that remains of process, and the software development of process end is not had specific (special) requirements, and is compatible good.
By a preferred embodiment the present invention is further specified again below.Present embodiment can be expanded Nucleus PLUS operating system and realize the process support.Nucleus PLUS operating system is the formula multithreading embedded OS of trying to be the first that designs for real-time embedded application, is widely used in the embedded products such as network service.
Create process according to following steps in the present embodiment:
Step 201, initialize process is course allocation PID.And in process list the relation between the process control block (PCB) of record the process PID and this process;
Step 202, the TCCE_Create_Task () api interface that calling Nucleus PLUS operating system provides is created an agent thread, and imports the pid value that distributes in the step 201 into to this agent thread.The dispatching priority of this agent thread and timeslice Configuration Values be identical with new process all;
Step 203 is finished agent thread and is created the pointer that the TCCE_Create_Task () api interface of back Nucleus PLUS operating system can return the thread control block of agent thread, this pointer is kept in the process control block (PCB) of new process.
When being moved by the scheduler schedules of Nucleus PLUS operating system, this agent thread will carry out following operation:
Step 301, the PID that imports into when creating process is saved in the tc_argv field of self thread control block, and TCD_Current_Thread->tc_argv that Nucleus PLUS operating system promptly is set is PID;
Step 302 is called return_to_process () function.
The treatment step of return_to_process () function is as follows:
Step 401 is taken out pid value from the thread control block of current thread, promptly read the TCD_Current_Thread->tc_argv value of Nucleus PLUS operating system;
Step 402, lookup process is tabulated, and finds the process control block (PCB) of corresponding process according to PID;
Step 403 reads information from process control block (PCB), use certain process resource to isolate handoff technique and switch to this required process resource space of process operation;
Step 404 reads information from process control block (PCB), the running status of recovering process;
Step 405 jumps in the code of process, and processor resource is transferred process.
The treatment step of acting on behalf of place, interrupt service routine main entrance in system is as follows:
Step 501, check the interrupt return address that processor is preserved when interrupting arriving, the address of this address instruction that to be exactly processor carrying out in the moment of interrupting producing, if this address is positioned at outside the proceeding internal memory spatial dimension of process, then think current interrupted be thread, jump to step 504, otherwise execution in step 502; The proceeding internal memory space can produce when the process of establishment, also can in the process that process is carried out, produce as required, specifically isolate handoff technique by process resource, as: the distribution of technology implementation process memory headrooms such as proceeding internal memory page table, process file table, isolation and switching.
Step 502 is saved in the running status of current process in the process control block (PCB) of this process;
Step 503 with the address that interrupt return address is revised as return_to_process () function, has two purposes like this:
A) interrupt service routine of Nucleus PLUS operating system is when handling interrupt in the step 4, and what can think that current interruption interrupts is agent thread;
B) scheduler of Nucleus PLUS operating system is after redistributing processor resource to agent thread next time, and agent thread can begin to carry out from return_to_process () function, again processor resource is transferred process.
Step 504 jumps to the interrupt service routine of Nucleus PLUS operating system, continues the interrupt response process.
The present invention kills a process according to following steps:
Step 601 finds the agent thread of this process correspondence in the process control block (PCB) of this process;
Step 602, the TCCE_Terminate_Task () api interface that calls Nucleus PLUS operating system stops this agent thread;
Step 603 is called the TCCE_Delete_Task () api interface of Nucleus PLUS operating system and is deleted this agent thread;
Step 604, the deletion list item relevant from process list with this process;
Step 605 discharges all resources that this process takies.
Fig. 6 has provided a kind of device embodiment one synoptic diagram that implementation process is supported in multi-threaded system of the present invention, and described device comprises creation module M1, process module M2, agent thread module M3 and resource distribution module M4;
Described creation module M1 is used for the establishment process, and the agent thread of described process correspondence;
Described process module M2 is connected with creation module M1, is used for the maintenance process relevant information;
Described agent thread module M3 is connected with creation module M1, is used for maintenance proxy thread relevant information;
Described resource distribution module M4 is connected with agent thread module M3 with creation module M1, process module M2, is used for described processor resource being transferred the process of described agent thread correspondence after described agent thread obtains the processor resource of scheduler distribution.
Fig. 7 has provided a kind of device embodiment two synoptic diagram that implementation process is supported in multi-threaded system of the present invention, present embodiment is except the architectural feature that comprises device embodiment one, and described resource distribution module M4 comprises that also process searches unit M41, resource space switch unit M42, running status recovery unit M43 and code performance element M44;
Described process is searched unit M41 and is used for searching the process of described agent thread correspondence after described agent thread obtains the processor resource of scheduler distribution;
Described resource space switch unit M42 searches unit M41 with process and is connected, and is used to switch to the process resource space of described process;
Described running status recovery unit M43 searches unit M41 with process and is connected with resource space switch unit M42, is used to recover described running state of a process;
Described code performance element M44 searches unit M41 with process and is connected with resource space switch unit M42, is used to carry out the code of described process.
Fig. 8 has provided a kind of device embodiment three synoptic diagram that implementation process is supported in multi-threaded system of the present invention, present embodiment is except the architectural feature that comprises device embodiment one, also comprise and act on behalf of break in service module M5, be connected with agent thread module M3 with process module M2, be used for when receiving interruption, what check current operation is process or thread, if thread is then carried out the interrupt service routine of multi-threaded system, if process then is saved in the running status of current process in the process control block (PCB) of described process, the processor resource that process is used transfers the agent thread of described process correspondence, and carries out the interrupt service routine of multi-threaded system.
The current operation of described inspection be that process or thread specifically can be judged according to following method: check the interrupt return address that processor is preserved when interrupting arriving, the address of this address instruction that to be exactly processor carrying out in the moment of interrupting producing, if this address is positioned at outside the proceeding internal memory spatial dimension of process, then think current interrupted be thread, the proceeding internal memory space can produce when the process of establishment, also can in the process that process is carried out, produce as required, specifically isolate handoff technique by process resource, as: the proceeding internal memory page table, the distribution of technology implementation process memory headrooms such as process file table, isolate and switching.
Present embodiment can also carry out above-mentioned expansion except carrying out the above-mentioned expansion on the basis of device embodiment two on the basis of device embodiment one.
Fig. 9 has provided a kind of device embodiment four synoptic diagram that implementation process is supported in multi-threaded system of the present invention, present embodiment is except the architectural feature that comprises device embodiment three, comprise that also process finishes module M6, be connected with agent thread module M3 with process module M2, be used for after the order that receives the process of killing, searching the agent thread of described process correspondence; Stop described agent thread; Delete described agent thread; The list item relevant in the deletion system with described process; Discharge the resource that described process takies.
Present embodiment can also carry out above-mentioned expansion except carrying out the above-mentioned expansion on the basis of device embodiment one or device embodiment two on the basis of device embodiment three.
Figure 10 has provided the multi-threaded system embodiment synoptic diagram that a kind of implementation process of the present invention is supported, comprises that said apparatus embodiment one implements the described arbitrary device of four examples to device, also comprises Scheduler module M7 and original break in service module M8;
Comprise that with described multi-threaded system device embodiment four is an example,
Described Scheduler module M7 and resource distribution module M4 with act on behalf of break in service module M5 and be connected, be used to carry out the scheduling of agent thread and the distribution of processor resource;
Described original break in service module M8 with act on behalf of break in service module M5 and be connected with Scheduler module M7, be used to carry out the thread interrupt response.
The present invention participates in schedule activities by the mode of creating agent thread by thread replacement process, makes the scheduler of original system still only need to be responsible for multithread scheduling, thereby does not need scheduler is carried out any modification.Because scheduler does not change, and system Central Plains has the scheduling behavior of thread also any change can not take place, original software module is still moved under multi-thread environment simultaneously.Therefore each software module does not need to make any modification because of the introducing of process yet in the original system.So just reached the purpose that implementation process is supported under the prerequisite of not changing original system, minimum to the original system influence.
The present invention uses agent thread replacement process to participate in schedule activities in the old system.Because the existence of agent thread, process shields invisible fully to original system, and the original part in the original system does not need to do any revision, makes that the invention process amount of getting up to work is little, risk is low, thereby easy to implement.And, do not need to be concerned about the scheduling strategy of original system during the invention process because the schedule activities of agent thread is still implemented by the scheduler of original system yet, and therefore going for any embedded multithreading operation system, versatility is good.
Be responsible for the processor resource of its acquisition is transferred process by agent thread, the processor resource of implementation process distributes, from the angle of process, process also perception less than the existence of agent thread.Therefore the present invention has shielded the thread scheduling details of original system to process, presents to the traditional multi-process running environment that remains of process, and the software development of process end is not had specific (special) requirements, and is compatible good.
The present invention can the multithreading operation system for original system add the process support function on the basis of not changing the original software code of original system.And the scheme that the present invention proposes goes for all main flow multithreading embedded OSs at present, and as Nucleus PLUS, VxWorks etc., versatility is good.The change workload is little during concrete enforcement, risk is low, cost is low.And can the original code of complete reservation original system, greatly prolonged the life cycle of old system.
It should be noted that at last: above embodiment only in order to technical scheme of the present invention to be described, is not intended to limit; Although with reference to previous embodiment the present invention is had been described in detail, those of ordinary skill in the art is to be understood that: it still can be made amendment to the technical scheme that aforementioned each embodiment put down in writing, and perhaps part technical characterictic wherein is equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution break away from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (10)

1. method that implementation process is supported in multi-threaded system is characterized in that described method comprises:
The establishment process;
Create the agent thread of described process correspondence; Described agent thread is dispatched by scheduler and is realized replacing its corresponding process to line up in the scheduling queue of scheduler;
Obtain the processor resource of described scheduler distribution when described agent thread after, described processor resource is transferred the process of described agent thread correspondence.
2. method according to claim 1 is characterized in that, the described process that described processor resource is transferred described agent thread correspondence is specially:
Search the process of described agent thread correspondence;
Switch to the process resource space of described process;
Recover described running state of a process;
Carry out the code of described process.
3. method according to claim 1 and 2 is characterized in that, also comprises:
When receiving interruption, what check current operation is process or thread, if thread is then carried out the interrupt service routine of multi-threaded system, if process then is saved in the running status of current process in the process control block (PCB) of described process, the processor resource that process is used transfers the agent thread of described process correspondence, and carries out the interrupt service routine of multi-threaded system.
4. method according to claim 3 is characterized in that, also comprises: after the order that receives the process of killing, search the agent thread of described process correspondence; Stop described agent thread; Delete described agent thread; Delete the information relevant with described process; Discharge the resource that described process takies.
5. method according to claim 2 is characterized in that,
Also comprise after the described establishment process: described course allocation process is numbered, and in process list, write down the corresponding relation of described process and process numbering;
Also comprise after the agent thread of the described process correspondence of described establishment: described agent thread writes down the process numbering of described process;
Described process of searching described agent thread correspondence is specially: the process of searching described agent thread correspondence according to the process numbering.
6. the device that implementation process is supported in multi-threaded system is characterized in that, comprises creation module, process module, agent thread module and resource distribution module;
Described creation module is used for the establishment process, and the agent thread of described process correspondence; Described agent thread is dispatched by scheduler and is realized replacing its corresponding process to line up in the scheduling queue of scheduler;
Described process module is connected with creation module, is used for the maintenance process relevant information;
Described agent thread module is connected with creation module, is used for maintenance proxy thread relevant information;
Described resource distribution module is connected with creation module, process module and agent thread module, is used for described processor resource being transferred the process of described agent thread correspondence after described agent thread obtains the processor resource of scheduler distribution.
7. device according to claim 6 is characterized in that, described resource distribution module comprises that process searches unit, resource space switch unit, running status recovery unit and code performance element;
Described process is searched the unit and is used for searching the process of described agent thread correspondence after described agent thread obtains the processor resource of scheduler distribution;
Described resource space switch unit is searched the unit with process and is connected, and is used to switch to the process resource space of described process;
Described running status recovery unit is searched the unit with process and is connected with the resource space switch unit, is used to recover described running state of a process;
Described code performance element is searched the unit with process and is connected with the resource space switch unit, is used to carry out the code of described process.
8. according to claim 6 or 7 described devices, it is characterized in that, also comprise and act on behalf of the break in service module, be connected with the agent thread module with the process module, be used for when receiving interruption, what check current operation is process or thread, if thread is then carried out the interrupt service routine of multi-threaded system, if process then is saved in the running status of current process in the process control block (PCB) of described process, the processor resource that process is used transfers the agent thread of described process correspondence, and carries out the interrupt service routine of multi-threaded system.
9. device according to claim 8 is characterized in that, comprises that also process finishes module, is connected with the agent thread module with the process module, is used for searching the agent thread of described process correspondence after the order that receives the process of killing; Stop described agent thread; Delete described agent thread; The list item relevant in the deletion system with described process; Discharge the resource that described process takies.
10. the multi-threaded system that implementation process is supported is characterized in that, comprises the described arbitrary device of claim 6-9, also comprises scheduler and original break in service module;
Described scheduler is used to carry out the scheduling of agent thread and the distribution of processor resource;
Described original break in service module is used to carry out the thread interrupt response.
CN2009100843590A 2009-05-22 2009-05-22 Method for realizing process support, device and multithreading system Expired - Fee Related CN101556545B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2009100843590A CN101556545B (en) 2009-05-22 2009-05-22 Method for realizing process support, device and multithreading system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2009100843590A CN101556545B (en) 2009-05-22 2009-05-22 Method for realizing process support, device and multithreading system

Publications (2)

Publication Number Publication Date
CN101556545A CN101556545A (en) 2009-10-14
CN101556545B true CN101556545B (en) 2011-04-06

Family

ID=41174668

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2009100843590A Expired - Fee Related CN101556545B (en) 2009-05-22 2009-05-22 Method for realizing process support, device and multithreading system

Country Status (1)

Country Link
CN (1) CN101556545B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833120A (en) * 2011-06-14 2012-12-19 中兴通讯股份有限公司 Method and system for handling exception of network management server in quick test professional (QTP)
CN106293902A (en) * 2015-05-28 2017-01-04 宇龙计算机通信科技(深圳)有限公司 A kind of processor scheduling method and system

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887384A (en) * 2010-06-30 2010-11-17 中山大学 Markov model-based process timeslice length determining method
CN102184118B (en) * 2011-06-15 2013-09-11 奇智软件(北京)有限公司 System recovery method
CN103077052B (en) * 2012-12-28 2017-02-01 华为终端有限公司 Method and device for processing unsmooth operation problem of mobile terminal
CN104461730B (en) * 2013-09-22 2017-11-07 华为技术有限公司 A kind of virtual resource allocation method and device
CN103885427B (en) * 2014-03-31 2016-03-16 珠海万力达电气自动化有限公司 A kind of embedded computer guard method based on RTEMS operating system
US9396044B2 (en) * 2014-04-25 2016-07-19 Sony Corporation Memory efficient thread-level speculation
US20160072908A1 (en) * 2014-09-09 2016-03-10 James Dinan Technologies for proxy-based multi-threaded message passing communication
CN105117321B (en) * 2015-06-30 2018-07-31 浪潮(北京)电子信息产业有限公司 A kind of process management method and management of process terminal
CN106371912B (en) * 2015-07-21 2019-11-26 阿里巴巴集团控股有限公司 A kind of resource regulating method and device of streaming computing system
CN106488477B (en) * 2015-08-31 2019-12-27 展讯通信(上海)有限公司 Multi-network mode management method and system and mobile terminal
CN105843675B (en) * 2016-04-01 2020-06-26 腾讯科技(深圳)有限公司 Thread exit method and device
CN110018911B (en) * 2018-01-09 2024-01-23 斑马智行网络(香港)有限公司 Process management and inter-process communication method and device, computing equipment and storage medium
CN108989348A (en) * 2018-08-31 2018-12-11 福建星网智慧科技股份有限公司 The optimization method of wifidog based on gateway
CN112363779A (en) * 2020-11-25 2021-02-12 王志平 Safety control method for dynamic link program
WO2022155937A1 (en) * 2021-01-23 2022-07-28 王志平 Security control method for dynamic link program
CN114237532B (en) * 2021-11-30 2024-09-06 珠海全志科技股份有限公司 Multi-window implementation method, device and medium based on Linux embedded system
CN115718665B (en) * 2023-01-10 2023-06-13 北京卡普拉科技有限公司 Asynchronous I/O thread processor resource scheduling control method, device, medium and equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833120A (en) * 2011-06-14 2012-12-19 中兴通讯股份有限公司 Method and system for handling exception of network management server in quick test professional (QTP)
CN102833120B (en) * 2011-06-14 2017-06-13 中兴通讯股份有限公司 The abnormal method and system of NM server are processed in a kind of rapid automatized test
CN106293902A (en) * 2015-05-28 2017-01-04 宇龙计算机通信科技(深圳)有限公司 A kind of processor scheduling method and system

Also Published As

Publication number Publication date
CN101556545A (en) 2009-10-14

Similar Documents

Publication Publication Date Title
CN101556545B (en) Method for realizing process support, device and multithreading system
US9798595B2 (en) Transparent user mode scheduling on traditional threading systems
US7698540B2 (en) Dynamic hardware multithreading and partitioned hardware multithreading
KR100623217B1 (en) Scheduling method, recording medium for storing program to execute the method and realtime processing system
US7290261B2 (en) Method and logical apparatus for rename register reallocation in a simultaneous multi-threaded (SMT) processor
EP2316091B1 (en) Protected mode scheduling of operations
US8079035B2 (en) Data structure and management techniques for local user-level thread data
US9104500B1 (en) Lock-free job scheduler for multi-processor systems
US20070294578A1 (en) Method and apparatus for facilitating process migration
US10248456B2 (en) Method and system for providing stack memory management in real-time operating systems
CN103473129B (en) Multi-task queue scheduling system with scalable number of threads and implementation method thereof
US20180341510A1 (en) Virtual processor scheduling via memory monitoring
CN101876926A (en) Asymmetric software triple-computer hot backup fault-tolerant method
US8321874B2 (en) Intelligent context migration for user mode scheduling
KR20050004688A (en) Scheduling method and information processing system
US9354934B2 (en) Partitioned shared processor interrupt-intensive task segregator
Miao et al. Spotserve: Serving generative large language models on preemptible instances
US20190213033A1 (en) Optimizing Host CPU Usage Based on Virtual Machine Guest OS Power and Performance Management
US20080244592A1 (en) Multitask processing device and method
US20080178180A1 (en) Computer System and Method For Processing Data Using Continuous Processing Task
Bi et al. Research of key technologies for embedded Linux based on ARM
CN113485812B (en) Partition parallel processing method and system based on large-data-volume task
US20080256542A1 (en) Processor
CN115362434A (en) Task scheduling for distributed data processing
CN102117224A (en) Multi-core processor-oriented operating system noise control method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
DD01 Delivery of document by public notice

Addressee: Zhou Jian

Document name: Notification of Passing Examination on Formalities

C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20110406

Termination date: 20210522