CN100342342C - Java virtual machine implementation method supporting multi-process - Google Patents

Java virtual machine implementation method supporting multi-process Download PDF

Info

Publication number
CN100342342C
CN100342342C CNB2005100619949A CN200510061994A CN100342342C CN 100342342 C CN100342342 C CN 100342342C CN B2005100619949 A CNB2005100619949 A CN B2005100619949A CN 200510061994 A CN200510061994 A CN 200510061994A CN 100342342 C CN100342342 C CN 100342342C
Authority
CN
China
Prior art keywords
virtual machine
java virtual
stack
message
queue
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
CNB2005100619949A
Other languages
Chinese (zh)
Other versions
CN1790270A (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.)
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
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 Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CNB2005100619949A priority Critical patent/CN100342342C/en
Publication of CN1790270A publication Critical patent/CN1790270A/en
Application granted granted Critical
Publication of CN100342342C publication Critical patent/CN100342342C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

The present invention provides a realization method for supporting a Java virtual machine with multiple processes. The process management is integrated in the Java virtual machine, the dispatching conversion, the corresponding process communication mechanism and the control method of a memory of the progresses on the Java virtual machine are realized to cause a plurality of Java progresses to be simultaneously run on an instance of the Java virtual machine, and thereby, system resources can be saved in the concurrent situation of a plurality of Java programs, the concurrent efficiency of progresses is improved, and the expense of a dispatcher is reduced. The present invention has the significance for an embedded system environment, especially a Java operating system facing to an embedded system.

Description

Support the Java Virtual Machine implementation method of multi-process
Technical field
The present invention relates to java applet design language and operation system technology, relate to java applet operation realization technology and scheduling handoff technique and process space distribution technique, particularly relate to the Java Virtual Machine method of supporting multi-process.
Background technology
Java language is the cross-platform object-oriented high-level programming language of being released by Sun Microsystems, just obtains more and more important position in every field at present, has become one of most important programming language.
The executable code of Java language is the Java bytecode (Byte Code) of unified standard after the compiling, as long as on a platform, Java Virtual Machine is arranged, so all Java executable codes can move under this Java Virtual Machine is supported, thereby Java has cross-platform good characteristic.
Under the present Java Virtual Machine environment, there is not the notion of multi-process.The thread that defines in the Java language comprises an internal memory entry point address, an exit point address and the code sequence that can carry out in proper order.But the important difference of process and thread is thread and can not carries out separately that it has to operate in the program process that is in active state, and therefore can define thread is the sequence code stream with concurrency of program inside.The meaning of multithreading is that a plurality of logical blocks of an application program can carry out concomitantly.But multithreading also do not mean that a plurality of consumer process and carrying out, and operating system is not come distributing independent system resource to each thread as process independently yet.Process can be created its subprocess, and subprocess has different executable codes and datarams space with parent process.And at a plurality of thread shared data of the process memory headroom that is used for representing application program, but keep each thread to have independently execution stack and program execution context.In present operating system, the multi-course concurrency operation is very general, and will realize that a plurality of java applets are concurrent, and then the execution of each java applet all needs an independent Java Virtual Machine to support.This mode does not have too big problem under normal conditions, because the Java executable code is explained by virtual machine and is carried out, from the angle of host operating system (promptly support Java Virtual Machine operation operating system), be exactly one with the Java Virtual Machine process of a Java executable code as input.All relevant issues of multi-process can be handled by the management of process mechanism of operating system.But under some special circumstances, under the environment that does not have host operating system,, then must be responsible for the work of management of process by virtual machine if support multi-course concurrency to carry out.
Summary of the invention
The object of the present invention is to provide a kind of Java Virtual Machine method for designing of supporting multi-process.
The technical scheme that the present invention solves its technical matters employing is as follows:
1, a kind of Java Virtual Machine implementation method of supporting multi-process:
1) process switching method
By the process scheduling device of java virtual machine replacement operating system, be responsible for the scheduling of each process:
I, by the process three kinds of states that are in operation: operation, ready, wait for, in Java Virtual Machine, set up three kinds of process queues: operation queue, ready queue, waiting list;
II, ready queue be height according to priority, adopts deque to realize, the dispatching method of each formation adopts round-robin scheduling;
2) each process communication method
I, carry out communication with signal
Signal is the incident of being transmitted to a process by identical or different process; Signal is used for to a process notice anomalous event;
II, carry out communication with message queue
Message is exactly in fact the sequence of some words or byte, and it is kept in the Java Virtual Machine, and process can be come identification message by a kind of identifier; Message is transmitted between process by the method for message queue, and message queue is the lists of links of a message;
3) internal memory control method
Java Virtual Machine is each process creation memory headroom, guarantees that simultaneously the memory headroom of each process is isolated in logic mutually, and a process can not be visited the local variable of another process, and the memory headroom of a process comprises following components:
1. pile: the entity of all objects all is placed in the heap;
2. stack: each thread all has a stack;
3. method memory field: in store executable code;
Constant pool when 4. moving: the in store compilation phase is with regard to available all constants;
5. frame: each method call is corresponding to a frame of stack top, and this part distributes in stack;
6. local variable: distribute by frame;
7. operand stack: because the instruction set of Java Virtual Machine is the stack formula, so operand all must be placed in the stack operand stack that Here it is.Each frame is corresponding to an operand stack, and this part distributes in frame.
The present invention compares with background technology, and the useful effect that has is:
(1) saves system resource significantly; During each process initiation, no longer be each process that all will generate a Java Virtual Machine, but process joined in the process queue of virtual machine self to have only the process of a Java Virtual Machine in the operating system, save system resource significantly.
(2) the concurrent efficient of raising process.Switching between the process is directly carried out in Java Virtual Machine, and need not transfer to operating system scheduling again, has reduced the spending of scheduler, and the switch speed between each process is more efficient.
(3) support that multi-course concurrency is carried out under the no host operating system environment.Integrated process scheduling and communication means in the native system make the switching of each process and communication mutually no longer rely on operating system to finish, and under no host operating system environment, serve as the role of a micro-kernel, and it is concurrent to coordinate each process.
Description of drawings
Fig. 1 is the process status transition diagram;
Fig. 2 is an internal memory control synoptic diagram;
Fig. 3 is a process operation synoptic diagram.
Embodiment
1) process scheduling method
By the process scheduling device of java virtual machine replacement operating system, be responsible for the scheduling of each process:
I, by the process three kinds of states that are in operation: operation, ready, wait for, in Java Virtual Machine, set up three kinds of process queues: operation queue, ready queue, waiting list.
Running status: a process just is in running status when occupying processor;
Ready state: process such as wait take processor;
Waiting status: a process can not be carried out before some incident takes place, as disk operating;
Corresponding in Java Virtual Machine, set up three kinds of process queues: operation queue, ready queue, waiting list.Wherein, the process in the operation queue is in run mode, shares the CPU time sheet according to priority; Process in the ready queue is in ready attitude, waits for being placed into operation queue; The process of waiting list is in waiting status, waits for being waken up by signal or system event entering ready attitude.
These three kinds of states switch mutually in operating system, show in the system: after a process has obtained all resources, this process is entered the medium timeslice to be allocated of ready queue, in case acquisition timeslice, this process is just put into operation queue, also lack certain resource if process is removed cpu, this process is drained into waiting list; Be transferred to ready queue after process timeslice in the operation queue uses up,, then be transferred to waiting list if operation will be waited for certain incident during process; When resource satisfied, the process in the waiting list can be waken up by incident and signal and join in the ready queue.Conversion regime between each state is seen Fig. 1.
II, ready queue be height according to priority, adopts deque to realize, the dispatching method of each formation adopts round-robin scheduling.
Process is distinguished real-time process and common process on the whole, real-time process requires than higher system responses, the common process of face is less demanding to system responses, they between the two, real-time process should be moved prior to common process, so, the priority height of the common process of ratio that the priority of real-time process will be established, among the present invention, the ready queue of process adopts deque to realize, one is the higher real-time process formation of priority ratio, and one is the lower common process queue of priority ratio.
Java Virtual Machine is at first selected the process operation in the real-time queue, when being sky, real-time queue just selects the time-histories operation in the common process queue, and in each formation, decision by which process is moved, and adopts the round-robin scheduling method, and Java Virtual Machine produces a clock with certain gap periods ground and interrupts, when central broken hair is given birth to, the current process of moving is placed in the ready queue, selects the longest process operation of life period then from ready queue, and concrete steps are as follows:
1, to specify scheduling parameter when creating process, and the real-time priority and the trim values of process are set, trim values will be converted to the length of the timeslice of this task;
2, if this process is not waited for resource, then this process is joined in the ready queue.
3, the ready queue of scheduler program traversal is calculated the scheduling weights according to real-time priority, selects the highest task of weights to use cpu.
4, if the timeslice in the ready queue is 0, the timeslice of this task can be set then according to trim values, simultaneously this process is put into the end of ready queue.Repeating step 3.
5, current process initiatively withdraws from cpu owing to wait for resource, and then it adds in the waiting list.Repeating step 3.
2) each process communication method
I, carry out communication with signal
Signal is the incident of being transmitted to a process by identical or different process.Signal is used for to a process notice anomalous event.
Signal is the software simulation of hardware interrupts, when process is being carried out, almost all incident can take place at any time.This unpredictability means that signal is asynchronous.Not only signal can take place at any time, and the process of received signal can not have control yet when signal goes out.
Under many situations all signal can appear.Hardware anomalies is quoted as illegal internal memory, just can produce signal people.Software anomaly, as attempt to carry out write operation to a pipeline that does not read, also can produce a signal, the operation of terminal generation also can produce process in addition.
After process was received a signal, it can take one of following three kinds of measures to signal:
1., ignore this signal
2., catch this signal, this will cause carrying out one section special code that is called signal processor
3., allow to carry out the default action of signal
When causing the signal event to occur,, just produce a signal at certain process such as hardware anomalies.On the contrary, when process is taken measures to the signal that sends to it, just claim that this signal is sent.To be called signal unsettled producing signal and sending time interval between the signal.Sending signal can get clogged or be delayed.This signal is delayed always, up to be disengaged block or the process of receiving the deployment way of this signal is changed into ignore till, signal is disposed how response signal of the process that is meant.A process can be ignored signal, allow the operation of its acquiescence to take place, and perhaps handles this signal.A signal that gets clogged is also referred to as unsettled signal, and a signal set is represented multiple signal, and the signal mask of a process is that process is blocked the not signal set of transmissibility at present down.
II, carry out communication with message queue
Message is exactly in fact the sequence of some words or byte, and it is kept in the Java Virtual Machine, and process can be crossed a kind of identifier identification message.Message is transmitted between process by the method for message queue, and message queue is the lists of links of a message.When a message is added to message queue, this message can be added to the end of formation, but be different with general fifo queue, message in the message queue can be retrieved with some random order, can from formation, retrieve message to come out with the type of a message, from this respect, formation is similar in realization in conjunction with array.
To row, following operation is arranged at message:
1. create and open message queue
After creating the message queue success, set up a brand-new message queue, and the return messages queue identifier, message queue success back return messages queue identifier opened.
2. in formation, write message
When if message count reaches the maximal value of maximal value that single queue allows or total system in the formation, perhaps during Insufficient privilege, the transmission failure of message.When message sends successfully, message is written to the end of message queue.
3. read message in the formation
Can read message in the message queue according to condition, when reading successfully, message turns back to calling process, and the message in the deletion message queue.
4. delete message queue
With whole message queue deletion.
2. internal memory control
According to the Java Virtual Machine standard, the structure of its memory headroom specified as described below as shown in Figure 2 when a java applet was carried out:
1. pile.The entity of all objects all is placed in the heap.Among the Java to one to as if conduct interviews by reference, quote and can all in heap, create in fact but quote object pointed from allocation space in the stack.The object that Garbage Collection Mechanism is paid attention to is just piled.
2. stack.Each thread all has a stack, and is similar with the stack of C language, preserves the scene with stack during function call, and the local variable of function also all is an allocation space in stack.
3. method memory field: the method memory field also can carry out refuse collection in fact, but this is dispensable.The in store executable code in method memory field, Java Virtual Machine are explained then and are carried out just from reading command here.
Constant pool when 4. moving: the in store compilation phase, this part distributed in the method memory field with regard to available all constants.
5. frame: each method call is corresponding to a frame of stack top, and this part distributes in stack.
6. local variable: this part distributes in frame.
7. operand stack: because the instruction set of Java Virtual Machine is the stack formula, so operand all must be placed in the stack operand stack that Here it is.Each frame is corresponding to an operand stack, and this part distributes in frame.
Our Java Virtual Machine has all independently kept above-mentioned structure for each process, except heap.Because java applet does not allow the programmer directly to discharge the shared memory headroom of object, and Java does not have pointer, and the enforcement strong type checking, so program only limits to create object to the visit of heap and to the visit of native object, to other process to as if can't visit.So it is safe allowing all processes share a heap, and makes things convenient for refuse collection.
In order to support the concurrent execution of a plurality of processes, the Java Virtual Machine among the present invention can be each process creation memory headroom, guarantees that simultaneously the memory headroom of each process is isolated in logic mutually, and a process can not be visited the local variable of another process.But with the virtual memory difference of common operating system, refuse collection for convenience, the heap unified management that Java Virtual Machine is supported does not need all to establish a heap for each process.This has also embodied the advantage of supporting the multi-process Java Virtual Machine.If the corresponding Java Virtual Machine of each process, that is the unified management that impossible realize refuse collection.
Fig. 3 is the synoptic diagram of the whole service process of a process, and at first newly-built process is this course allocation internal memory, describes the internal memory control of seeing in the specific implementation method in detail, if the Memory Allocation failure, then this process finishes.Behind the storage allocation, process is dispatched, show as, this process is switched under ready, operation, three kinds of states of wait, the process switching method in the specific implementation method is seen in detailed description, and in addition, process is in operation and also will communicates, communication means is seen the process communication method in the specific implementation method, and finish process operation back.

Claims (1)

1, a kind of Java Virtual Machine implementation method of supporting multi-process is characterized in that:
1) process switching method
By the process scheduling device of java virtual machine replacement operating system, be responsible for the scheduling of each process:
I, by the process three kinds of states that are in operation: operation, ready, wait for, in Java Virtual Machine, set up three kinds of process queues: operation queue, ready queue, waiting list;
II, ready queue be height according to priority, adopts deque to realize, the dispatching method of each formation adopts round-robin scheduling;
2) each process communication method
I, carry out communication with signal
Signal is the incident of being transmitted to a process by identical or different process; Signal is used for to a process notice anomalous event;
II, carry out communication with message queue
Message is exactly in fact the sequence of some words or byte, and it is kept in the Java Virtual Machine, and process can be come identification message by a kind of identifier; Message is transmitted between process by the method for message queue, and message queue is the lists of links of a message;
3) internal memory control method
Java Virtual Machine is each process creation memory headroom, guarantees that simultaneously the memory headroom of each process is isolated in logic mutually, and a process can not be visited the local variable of another process, and the memory headroom of a process comprises following components:
1. pile: the entity of all objects all is placed in the heap;
2. stack: each thread all has a stack;
3. method memory field: in store executable code;
Constant pool when 4. moving: the in store compilation phase is with regard to available all constants;
5. frame: each method call is corresponding to a frame of stack top, and this part distributes in stack;
6. local variable: distribute by frame;
7. operand stack: because the instruction set of Java Virtual Machine is the stack formula, so operand all must be placed in the stack operand stack that Here it is; Each frame is corresponding to an operand stack, and this part distributes in frame.
CNB2005100619949A 2005-12-14 2005-12-14 Java virtual machine implementation method supporting multi-process Expired - Fee Related CN100342342C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100619949A CN100342342C (en) 2005-12-14 2005-12-14 Java virtual machine implementation method supporting multi-process

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100619949A CN100342342C (en) 2005-12-14 2005-12-14 Java virtual machine implementation method supporting multi-process

Publications (2)

Publication Number Publication Date
CN1790270A CN1790270A (en) 2006-06-21
CN100342342C true CN100342342C (en) 2007-10-10

Family

ID=36788162

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100619949A Expired - Fee Related CN100342342C (en) 2005-12-14 2005-12-14 Java virtual machine implementation method supporting multi-process

Country Status (1)

Country Link
CN (1) CN100342342C (en)

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101097527B (en) * 2006-06-27 2011-11-30 中国银联股份有限公司 Flowpath scheduling method and system of application progress
JP2009543236A (en) * 2006-07-14 2009-12-03 インテル コーポレイション Heap organization for multitasking virtual machines
CN100428166C (en) * 2006-12-31 2008-10-22 华为技术有限公司 Processing method for use in client terminal having an access to EJB through remote interface and device therefor
CN100530107C (en) * 2007-03-02 2009-08-19 中国科学院声学研究所 Single process contents server device and method based on IO event notification mechanism
CN101493786B (en) * 2008-01-22 2012-07-04 联想(北京)有限公司 Computer virtual machine system and equipment accessing method
CN101221535B (en) * 2008-01-25 2010-06-09 中兴通讯股份有限公司 Garbage recovery mobile communication terminal of Java virtual machine and recovery method thereof
CN101262498B (en) * 2008-04-22 2011-01-05 华为技术有限公司 A distributed message call method and device
CN101751335B (en) * 2008-11-28 2012-01-18 国际商业机器公司 Method, device and cluster system for collecting rubbish of scheduling virtual machine
CN101576829B (en) * 2009-06-12 2011-08-24 宋志飞 Trusteeship method and system for application process in embedded linux system
CN101876918B (en) * 2009-11-27 2013-02-13 北京航空航天大学 Synchronous task sensing method of virtual machine client operation system
CN102222037B (en) * 2010-04-15 2014-04-02 国际商业机器公司 Method and equipment for positioning bottleneck of JAVA program
CN102023896A (en) * 2010-12-20 2011-04-20 复旦大学 Dispatcher of Java virtual machine-based concurrent garbage collector
CN102970353B (en) * 2012-11-08 2015-04-08 大唐软件技术股份有限公司 Method and system for business data processing
CN104636200B (en) * 2013-11-14 2019-03-29 上海计算机软件技术开发中心 A kind of method of computer multi-process equity dispatching
CN106909436B (en) * 2015-12-23 2020-07-21 财团法人工业技术研究院 Method and system for generating correlation of virtual machine message queue application program
US20200233677A2 (en) * 2018-04-11 2020-07-23 Smart Enterprises, Inc. Dynamically-Updatable Deep Transactional Monitoring Systems and Methods
CN108958914A (en) * 2018-06-16 2018-12-07 温州职业技术学院 A kind of dynamic multi-level feedback queue process scheduling method based on time supervision
CN109240812A (en) * 2018-08-05 2019-01-18 温州职业技术学院 A kind of process Optimization Scheduling based on dynamic monitoring
CN110968361B (en) * 2019-11-04 2021-11-23 上海交通大学 Isolation sandbox loading method
CN113515388A (en) * 2021-09-14 2021-10-19 统信软件技术有限公司 Process scheduling method and device, computing equipment and readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1516831A (en) * 2001-03-29 2004-07-28 国际商业机器公司 Wordload management of stateful program entities
US6850953B1 (en) * 1999-08-23 2005-02-01 Sun Microsystems, Inc. Creating multiple sets of data by spawning a secondary virtual machine
CN1630852A (en) * 2001-09-28 2005-06-22 英特尔公司 Flexible acceleration of JAVA thread synchronization on multiprocessor computers

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6850953B1 (en) * 1999-08-23 2005-02-01 Sun Microsystems, Inc. Creating multiple sets of data by spawning a secondary virtual machine
CN1516831A (en) * 2001-03-29 2004-07-28 国际商业机器公司 Wordload management of stateful program entities
CN1630852A (en) * 2001-09-28 2005-06-22 英特尔公司 Flexible acceleration of JAVA thread synchronization on multiprocessor computers

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
利用Java的多线程技术实现并行多任务的管理 杨绍方,电脑编程技巧与维护,第2期 2001 *

Also Published As

Publication number Publication date
CN1790270A (en) 2006-06-21

Similar Documents

Publication Publication Date Title
CN100342342C (en) Java virtual machine implementation method supporting multi-process
CN102541653B (en) Method and system for scheduling multitasking thread pools
CN1117319C (en) Method and apparatus for altering thread priorities in multithreaded processor
CN101051280A (en) Intelligent card embedded operation system and its control method
JP5597196B2 (en) Scheduler instance in process
AU2007261666C1 (en) Method, system, and apparatus for scheduling computer micro-jobs to execute at non-disruptive times
CN1112636C (en) Method and apparatus for selecting thread switch events in multithreaded processor
CN1208721C (en) Graded task switching method based on PowerPC processor structure
CN1867891A (en) Method and apparatus for real-time multithreading
CN1752896A (en) Power source management method of embedded equipment under operation system cooperation and its system
CN1160247A (en) System and method for space efficient object locking
CN1601478A (en) Method and system for dynamically bounded spinning threads on a contested mutex
CN1582428A (en) Method and apparatus for dispatching tasks in a non-uniform memory access (NUMA) computer system
CN1908903A (en) System and method for executing job step, and computer product
CN102375761A (en) Business management method, device and equipment
CN1801101A (en) Thread implementation and thread state switching method in Java operation system
CN1432913A (en) System and method of managing drives in computer system
CN101079902A (en) A great magnitude of data hierarchical storage method
CN1613059A (en) A method and a system for executing operating system functions, as well as an electronic device
JP2011521354A (en) A local set of tasks in the scheduler
CN1702623A (en) Task level resource administration method for micro-kernel embedded real-time operation systems
CN100346307C (en) Method of real time task regulation in Java operation system
CN101414270A (en) Method for implementing assist nuclear task dynamic PRI scheduling with hardware assistant
CN1317640C (en) Multi-task application software module management method in real-time operating system environment
CN1423456A (en) Sharing route realizing and sheduling 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
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20071010

Termination date: 20111214