欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    An Insider's View to Concurrency at Microsoft.ppt

    • 资源ID:378280       资源大小:1.33MB        全文页数:17页
    • 资源格式: PPT        下载积分:2000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要2000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    An Insider's View to Concurrency at Microsoft.ppt

    1、An Insiders View to Concurrency at Microsoft,Stephen Toub () Parallel Computing Platform Microsoft Corporation,Agenda,Why We (I) Care What Weve Built for Developers What Were Building for Developers,Moores Law: Alive and Well,http:/upload.wikimedia.org/wikipedia/commons/2/25/Transistor_Count_and_Moo

    2、re%27s_Law_-_2008_1024.png,MS Apps Using Parallelism Example: Visual Studio,Background compilation Regex-based file search Graph layout Reference highlighting IntelliSense sorting Project build system Code analysis Unit testing ,But its not just about core count,Increasingly connected applications M

    3、ore latency e.g. everything as a service More UI responsiveness problems e.g. the toilet bowl of death More scalability issues Server, Cloud e.g. streaming data sources, data distribution Client e.g. modeling interacting biological entities Async-only APIs e.g. Silverlight,The Challenges of Concurre

    4、ncy,A different way of thinking Forcing the square peg (concurrency) into the round hole (sequential) is a common (inadequate) mistake Parallel patterns are not prevalent, well known, nor easy to implement CS curriculum is still largely “sequential”: Cormen, et. al; Knuth; etc.A different way of wri

    5、ting software Indeterminate program behavior No longer: “A happens, then B happens, then C happens” Its just: “A, B, and C happen” With distinct costs, too Deadlocks, livelocks, latent race conditions, priority inversions, hardware-specific memory model reordering, Businesses have little desire to g

    6、o deep Best devs should focus on business value, not concurrency Need simple ways to allow all devs to write concurrent code,Example: Searching and Sorting,IEnumerable drivers = .; var results = new List(); foreach(var driver in drivers) if (driver.Name = queryName ,Manual Parallel Solution,IEnumera

    7、ble drivers = ; var results = new List(); int partitionsCount = Environment.ProcessorCount; int remainingCount = partitionsCount; var enumerator = drivers.GetEnumerator(); try using (var done = new ManualResetEvent(false) for(int i = 0; i = queryWinCount) lock(results) results.Add(driver);if (Interl

    8、ocked.Decrement(ref remainingCount) = 0) done.Set(););done.WaitOne();results.Sort(b1, b2) = b1.Age.CompareTo(b2.Age); finally if (enumerator is IDisposable) (IDisposable)enumerator).Dispose(); ,LINQ Solution,IEnumerable drivers = .; var results = from driver in driverswhere driver.Name = queryName ,

    9、.AsParallel(),P,Demo,PLINQ,Visual Studio 2010 Tools, Programming Models, Runtimes,Parallel Pattern Library,Resource Manager,Task Scheduler,Task Parallel Library,Parallel LINQ,Managed,Native,Key:,Threads,Operating System,Concurrency Runtime,Programming Models,ThreadPool,Task Scheduler,Resource Manage

    10、r,Data Structures,Data Structures,Tools,Tooling,Parallel Debugger Tool Windows,Profiler Concurrency Visualizer,Async Agents Library,UMS Threads,.NET Framework 4,Visual C+ 2010,Visual Studio 2010,Windows,Investigations for the future,This is some synchronous code with .NET 4,public void CopyStreamToS

    11、tream(Stream source, Stream destination) byte buffer = new byte0x1000; int numRead; while (numRead = source.Read(buffer, 0, buffer.Length) != 0) destination.Write(buffer, 0, numRead); ,This is an experts asynchronous code with .NET 4,public void CopyStreamToStream(Stream source, Stream destination)

    12、byte buffer = new byte0x1000; int numRead; while (numRead = source.Read(buffer, 0, buffer.Length) != 0) destination.Write(buffer, 0, numRead); ,public IAsyncResult BeginCopyStreamToStream(Stream source, Stream destination) var tcs = new TaskCompletionSource(); byte buffer = new byte0x1000;Action rea

    13、dWriteLoop = null; readWriteLoop = iar = try for (bool isRead = iar = null; ; isRead = !isRead) switch (isRead) case true: iar = source.BeginRead(buffer, 0, buffer.Length, readResult = if (readResult.CompletedSynchronously) return; readWriteLoop(readResult); , null); if (!iar.CompletedSynchronously)

    14、 return; break; case false: int numRead = source.EndRead(iar); if (numRead = 0) tcs.TrySetResult(null); return; iar = destination.BeginWrite(buffer, 0, numRead,writeResult = if (writeResult.CompletedSynchronously) return; destination.EndWrite(writeResult); readWriteLoop(null); , null); if (!iar.Comp

    15、letedSynchronously) return; destination.EndWrite(iar); break; catch (Exception e) tcs.TrySetException(e); ; readWriteLoop(null);return tcs.Task; public void EndCopyStreamToStream(IAsyncResult asyncResult) (Task)asyncResult).Wait(); ,A compiler could do the work for us,public void CopyStreamToStream(

    16、Stream source, Stream destination) byte buffer = new byte0x1000; int numRead; while (numRead = source.Read(buffer, 0, buffer.Length) != 0) destination.Write(buffer, 0, numRead); ,public Task CopyStreamToStream(Stream source, Stream destination) byte buffer = new byte0x1000; int numRead; while (numRe

    17、ad = await source.ReadAsync(buffer, 0, buffer.Length) != 0) await destination.WriteAsync(buffer, 0, numRead); ,public Task CopyStreamToStream(Stream source, Stream destination) byte buffer = new byte0x1000; int numRead; while (numRead = await source.ReadAsync(buffer, 0, buffer.Length) != 0) await destination.WriteAsync(buffer, 0, numRead); ,Q&A,


    注意事项

    本文(An Insider's View to Concurrency at Microsoft.ppt)为本站会员(figureissue185)主动上传,麦多课文档分享仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文档分享(点击联系客服),我们立即给予删除!




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1 

    收起
    展开