Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101014 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6528 invoked from network); 1 Nov 2017 10:15:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2017 10:15:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 104.47.42.128 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 104.47.42.128 mail-by2nam03on0128.outbound.protection.outlook.com Received: from [104.47.42.128] ([104.47.42.128:53714] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/C9-07742-5BE99F95 for ; Wed, 01 Nov 2017 05:15:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ygXnTWBLixNjOQfZO4v+NwZBqKQwZtCfSD/RvWwD0xc=; b=cKO33RU26yg32JGJ+e3GTycA7TP471swBbLCMbwwCuO+yGiDggt6Ffwquzc7pv7qdf9GK2CYeiGn5KSx3XG1cgoxQ27PBarPMaKeOMGyTmIqscZDS1hnWz6PfMJiWrpv0tI8qD7Pr6lHabHRpkZkAJ75it/ZFawISnL2IY4pYi8= Received: from BN6PR02MB3234.namprd02.prod.outlook.com (10.161.152.32) by BN6PR02MB3234.namprd02.prod.outlook.com (10.161.152.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Wed, 1 Nov 2017 10:15:12 +0000 Received: from BN6PR02MB3234.namprd02.prod.outlook.com ([10.161.152.32]) by BN6PR02MB3234.namprd02.prod.outlook.com ([10.161.152.32]) with mapi id 15.20.0156.006; Wed, 1 Nov 2017 10:15:12 +0000 To: Haitao Lv CC: PHP Internals , Nikita Popov , Bob Weinand Thread-Topic: [PHP-DEV] RFC - Zend VM Pause API Thread-Index: AQHTUq+MRlKJxgZnpUWrjGakEM4VPKL/Kb/IgAAPDQCAAARLE4AABjkAgAADi4CAAAIcew== Date: Wed, 1 Nov 2017 10:15:12 +0000 Message-ID: References: <736B46E8-9458-4E63-8BB7-AF93A8C35F58@lvht.net> <358E7BE8-F3D3-47BC-AD44-21B0A9D4ABA5@lvht.net>,<0C785312-A09B-4E44-A1F2-40964C5AECBF@lvht.net> In-Reply-To: <0C785312-A09B-4E44-A1F2-40964C5AECBF@lvht.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [213.21.45.232] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR02MB3234;6:fF85yP11Y5pE2+Y1ZhPIXTUHlc23W+HLWsCKPO0ZAMdjhm17+iufqKkFDeAjV0ISiJJAFAQCa2VjD6VR3FCS2DG3aFxS+PQPs7LQcbIc49izUD052fUcJzpPg01Xz24psajV9eErI55omjiqnmL22iaIMocQ9MBaRRQuH0uHmS85GGPk8GvDi8t5trq+aXNCVVWGpcg2DjoN8HoMyfnqveQJer2ACF+jaYj5UbHJnVVhunTPzg9t+8PIbjOv7tmHT2lSCP2qQ2tf7eUQfbDXA3zQsDSJU0bDvc6mEJYiZqRLTauzXjWHMcMFYqMSQEBOMVOySYVwemanoX1ZU3OJDw==;5:lr68WcBVz52//N9pqmc4xodElCMvQckeGp4l6X1zNUAnmjVSeGUMIhg3RHgmXabXO10s5Y3nO92C2sZFqIhIUY5fZthi7ahlBgiQfZOQUTGinSjZcJtKSXRwLSoRxqBPavD9AiEMPHeFNsKJG4XEoA==;24:HprVSy39S7yq6Srr84HkK/zHurCojQ2OpizzorXmvmxYzCdJmkWAVhxgsKbySvqTXJqcIeWZQwB0Fpmpnl0eQbC4dtfYdW0ZDmW0nVBq5L0=;7:FXyG7Uan+kE4W6culIRrGTBrCggETkX7Vqe8jw58tsvKBoTL1nvAdV+hSzvysCcU2NZtdA5e4Sph4J8uXnZPIYlM5KFRpqRyk/+SaqpANLJ7hLf2tGiRlQQSwgvhxHUNxBg3WujJeCriNSZq/G1/Y6Oy++oVQic/AITBi5VGqcXSZ7NVoPe0VJZkmkYSmlebA0ffRzvx7G2vcfRFNmJmiJFYHJb5yCXYkjE7ooc8Spk= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 98b9ddf9-e068-4545-721b-08d52111701a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(2017052603199);SRVR:BN6PR02MB3234; x-ms-traffictypediagnostic: BN6PR02MB3234: x-exchange-antispam-report-test: UriScan:(158342451672863)(23657631684272)(166708455590820); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(3231020)(6041248)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR02MB3234;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR02MB3234; x-forefront-prvs: 0478C23FE0 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(376002)(199003)(24454002)(189002)(50986999)(2900100001)(54906003)(8676002)(3280700002)(54356999)(39060400002)(97736004)(53936002)(54896002)(101416001)(966005)(3660700001)(14454004)(189998001)(33656002)(105586002)(6506006)(6436002)(76176999)(106356001)(93886005)(7736002)(81156014)(229853002)(3846002)(5660300001)(102836003)(16799955002)(86362001)(478600001)(236005)(6246003)(8936002)(7696004)(74316002)(6116002)(4326008)(2950100002)(77096006)(4743002)(316002)(6916009)(55016002)(53546010)(6306002)(606006)(9686003)(68736007)(2906002)(66066001)(15188155005)(81166006)(99286003)(25786009)(781001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR02MB3234;H:BN6PR02MB3234.namprd02.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BN6PR02MB323456630CC60A7553EAF149BF5F0BN6PR02MB3234namp_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98b9ddf9-e068-4545-721b-08d52111701a X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2017 10:15:12.0328 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB3234 Subject: Re: [PHP-DEV] RFC - Zend VM Pause API From: dmitry@zend.com (Dmitry Stogov) --_000_BN6PR02MB323456630CC60A7553EAF149BF5F0BN6PR02MB3234namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I'm not sure, why do you need to exit from the current VM instance. It should be possible to perform fiber scheduling and VM context switch dir= ectly in interrupt handler (like in real OS). VM should handle this out of the box (at least VM interrupts were designed = with context switch in mind). In your case, I suppose, part of zend_fiber_resume() should be merged into = fiber_interrupt_function(). Also you should handle only your own interrupts (like ext/pcntl does checki= ng PCNTL_G(pending_signals)). Sorry, I don't have a lot of time to review your sources. However, the implementation is really interesting, and I'm glad, someone is= working on this. Thanks. Dmitry. ________________________________ From: Haitao Lv Sent: Wednesday, November 1, 2017 12:45:13 PM To: Dmitry Stogov Cc: PHP Internals Subject: Re: [PHP-DEV] RFC - Zend VM Pause API To make the discussion more detailed, please allow me to offer my implement= ation of use land coroutine(Fiber). https://github.com/php/php-src/compare/master...fiberphp:fiber-ext?expand= =3D1 > On 1 Nov 2017, at 17:32, Haitao Lv wrote: > > Suppose we have a internal Coroutine class and it has a resume() method. > > In order to resume the coroutine, we have to call the resume() function. > > As the resume function is a internal method defined in c, we need call > > zend_execute_ex(backuped_execute_data) > > to resume the zend execution. > > If we need to pause the coroutine, we set the EG(vm_interrupt) and interr= upt_function, > and switch the execute data and stack. The zend vm will execute the old o= nline. > > However, we will never see the resume() method returned and never get its= return value. > >> On 1 Nov 2017, at 17:14, Dmitry Stogov wrote: >> >> after zend_interrupt_function() callback VM continues execution using EG= (current_execute_data). >> callback may modify it in any way (e.g. unwind stack, or switch to anoth= er co-routine or continuation). >> >> Thanks. Dmitry. >> From: Haitao Lv >> Sent: Wednesday, November 1, 2017 11:54:54 AM >> To: Dmitry Stogov >> Cc: PHP Internals >> Subject: Re: [PHP-DEV] RFC - Zend VM Pause API >> >> It seems that set EG(vm_interrupt) to 1 could not stop the vm execution = but only execute the interrupt_function and continue the current execution. >> >> However, my RFC propose to stop the current execution. >> >>> On 1 Nov 2017, at 16:07, Dmitry Stogov wrote: >>> >>> Hi, >>> >>> It should be possible do similar things using EG(vm_interrupt) and zend= _interrupt_function() callback (introduced in php-7.1) >>> ext/pcntl implements asynchronous signal handling using this. >>> >>> Thanks. Dmitry. >>> From: Haitao Lv >>> Sent: Wednesday, November 1, 2017 4:19:07 AM >>> To: PHP Internals >>> Subject: [PHP-DEV] RFC - Zend VM Pause API >>> >>> Hi, internals, >>> >>> I propose to introduce a new zend vm pause api, and here is the RPF >>> >>> https://wiki.php.net/rfc/zend-vm-pause-api >>> >>> Please gave your comment. >>> >>> Thank you. >>> >>> >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --_000_BN6PR02MB323456630CC60A7553EAF149BF5F0BN6PR02MB3234namp_--